Last active
April 21, 2017 16:38
-
-
Save dtjm/3637cb711a3d4283f77180aaf4fa4903 to your computer and use it in GitHub Desktop.
HTTP server closes connection under Go 1.4.3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io/ioutil" | |
"log" | |
"net/http" | |
) | |
func main() { | |
log.SetFlags(log.LstdFlags | log.Lmicroseconds) | |
log.Println("listening on 127.0.0.1:10000") | |
err := http.ListenAndServe("127.0.0.1:10000", http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { | |
log.Printf("reading body") | |
body, _ := ioutil.ReadAll(req.Body) | |
log.Printf("read body: %s", string(body)) | |
// causes server to close connection on Go 1.4.3 | |
req.Body.Close() | |
})) | |
if err != nil { | |
log.Fatal(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Send a post body like this to trigger the connection close: