diff --git a/src/net/http/client.go b/src/net/http/client.go index a496f1c0c75..ec24516833c 100644 --- a/src/net/http/client.go +++ b/src/net/http/client.go @@ -265,6 +265,12 @@ func send(ireq *Request, rt RoundTripper, deadline time.Time) (resp *Response, d } return nil, didTimeout, err } + if resp == nil { + return nil, didTimeout, fmt.Errorf("http: RoundTripper implementation (%T) returned a nil *Response with a nil error", rt) + } + if resp.Body == nil { + return nil, didTimeout, fmt.Errorf("http: RoundTripper implementation (%T) returned a *Response with a nil Body", rt) + } if !deadline.IsZero() { resp.Body = &cancelTimerBody{ stop: stopTimer,