net/http: checks for nil Response or Response.Body in Client.send causing some internal Google tests to fail #38095
With https://golang.org/cl/221818, we do explicit checks to see if a
It’s documented that
Should we be enforcing a non-nil
The text was updated successfully, but these errors were encountered:
Reading the package docs, perhaps we could relax this check.
https://golang.org/pkg/net/http/#Response says (emphasis mine):
// The http Client and Transport guarantee that Body is always // non-nil, even on responses without a body or responses with // a zero-length body. It is the caller's responsibility to // close Body. The default HTTP client's Transport may not // reuse HTTP/1.x "keep-alive" TCP connections if the Body is // not read to completion and closed.
which to me implies a non-nil
CHANGES Apply fix provided by @davecheney in order to properly implement the RoundTripper interface's expected behavior: - return response and nil error OR - return nil and a non-nil error to explain failures to obtain a response I likely *over* explained this with doc comments, but I am still very much in "learning" mode here. REFERENCES - GH-46 - 2ce144f - 6db6217 - http://hassansin.github.io/Unit-Testing-http-client-in-Go - golang/go#41071 - golang/go#38095 - golang/go@2d77d33 - golang/go@12d02e7 - https://godoc.org/net/http#RoundTripper - https://godoc.org/net/http#Response - https://godoc.org/net/http#Response.Body