summaryrefslogtreecommitdiff
path: root/src/lib/http/triv.go
blob: a7eb35aa2b371b6da68469039b8cc25e3d08e06d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// 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())
	}
}