You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For an HTTP handler with no writes in its handler,
package main
import (
"net/http"
"log"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
... we don't deal with HTTP/1.0 requests with "Connection: keep-alive" ideally.
If we set a Content-Length: 0 header here, we wouldn't have to close the connection:
$ telnet localhost 8080
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.0
Connetion: keep-alive
HTTP/1.0 200 OK
Connection: close
Date: Fri, 24 Aug 2012 19:53:36 GMT
Content-Type: text/plain; charset=utf-8
Connection closed by foreign host.
We do the right thing for HTTP/1.1 (sending a chunked response and closing the chunk
stream).
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: