Skip to content

Commit

Permalink
Improve error message when proxy connection fails
Browse files Browse the repository at this point in the history
If the proxy doesn't respond to our CONNECT request with a 2XX status
code, we now display the proxy's response rather than the confusing
error "tls: first record does not look like a TLS handshake"

Kubernetes-commit: 674db522815df566ffae7fbe8daf5f8e3ced9033
  • Loading branch information
3point2 authored and k8s-publishing-bot committed Nov 2, 2022
1 parent 5d4cdd2 commit 553a2d6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/util/httpstream/spdy/roundtripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,15 @@ func (s *SpdyRoundTripper) dialWithHttpProxy(req *http.Request, proxyURL *url.UR

//nolint:staticcheck // SA1019 ignore deprecated httputil.NewProxyClientConn
proxyClientConn := httputil.NewProxyClientConn(proxyDialConn, nil)
_, err = proxyClientConn.Do(&proxyReq)
response, err := proxyClientConn.Do(&proxyReq)
//nolint:staticcheck // SA1019 ignore deprecated httputil.ErrPersistEOF: it might be
// returned from the invocation of proxyClientConn.Do
if err != nil && err != httputil.ErrPersistEOF {
return nil, err
}
if response != nil && response.StatusCode >= 300 || response.StatusCode < 200 {
return nil, fmt.Errorf("CONNECT request to %s returned response: %s", proxyURL.Redacted(), response.Status)
}

rwc, _ := proxyClientConn.Hijack()

Expand Down

0 comments on commit 553a2d6

Please sign in to comment.