I wrote a really simple server :
-----------------------------------------------------------------------------------------------------
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/", root)
fmt.Println("listening on port: 7777")
err := http.ListenAndServe(":7777", nil)
if err != nil {
panic(err)
}
}
func root(res http.ResponseWriter, req *http.Request) {
fmt.Fprintf(res, "Hello")
}
-----------------------------------------------------------------------------------------------------------------------------
When I do "curl localhost:7777/" I see "hello" printed in the response so
all is ok. But when I play the same request using netcat:
------------------------------------------------------------------------------------------------------------------------------
$> nc localhost 7777
GET / HTTP/1.1 #writing the request
manually
User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0
OpenSSL/0.9.8y zlib/1.2.5
Host: localhost:7777
Accept: */*
HTTP/1.1 200 OK #response headers
Content-Type: text/plain; charset=utf-8
Content-Length: 5
Date: Sun, 13 Oct 2013 18:42:55 GMT
Hello #here the
connection stays open just after "Hello", when I type return
HTTP/1.1 400 Bad Request # I see this and the
connection really close
------------------------------------------------------------------------------------------------------------------------------
What's happening here ? There is obviously something wrong but I can't tell
what.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/ea81d3d2-64ef-47ff-af73-ce66d7fbc3c8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.