1
0
mirror of https://github.com/golang/go synced 2024-10-05 02:31:21 -06:00
go/src/lib/http/triv.go

31 lines
598 B
Go
Raw Normal View History

// 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() {
err := http.ListenAndServe("0.0.0.0:12345", &Echo)
if err != nil {
panic("ListenAndServe: ", err.String())
}
}