I use simple client on golang
package main
import (
"fmt"
"net/http"
)
func main() {
_, err := http.Get("http://localhost:8080/health")
fmt.Println(err)
}
and simple http server on python https://gist.github.com/huyng/814831
but I got an error
Get "http://localhost:8080/health": net/http: HTTP/1.x transport connection broken: unexpected EOF
What is wrong with my client or server?
CodePudding user response:
...net/http: HTTP/1.x transport connection broken: unexpected EOF
What is wrong with my client or server?
The answer lies in the 6 year old comment immediately below the code you use for the server:
Nice. A minor HTTP protocol glitch though, as there's no self.end_headers() so the response is malformed when served to picky clients (haproxy). ;)
Thus, don't just take code from somewhere on the internet w/o understanding what it does. Especially, if there is already an explicitly comment saying that the code is broken