2008-09-24 16:26:55 -06:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io";
|
|
|
|
"bufio";
|
|
|
|
"os";
|
|
|
|
"net";
|
|
|
|
"http"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Echo(conn *http.Conn, req *http.Request) {
|
|
|
|
fd := conn.bw;
|
|
|
|
conn.close = true;
|
|
|
|
io.WriteString(fd, "HTTP/1.1 200 OK\r\n"
|
|
|
|
"Content-Type: text/plain\r\n"
|
|
|
|
"\r\n");
|
|
|
|
io.WriteString(fd, req.method+" "+req.rawurl+" "+req.proto+"\r\n")
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2008-10-08 10:34:50 -06:00
|
|
|
err := http.ListenAndServe("0.0.0.0:12345", &Echo);
|
2008-09-24 16:26:55 -06:00
|
|
|
if err != nil {
|
|
|
|
panic("ListenAndServe: ", err.String())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|