Skip to content

Commit 553a2d6

Browse files
3point2k8s-publishing-bot
authored andcommitted
Improve error message when proxy connection fails
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
1 parent 5d4cdd2 commit 553a2d6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/util/httpstream/spdy/roundtripper.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,15 @@ func (s *SpdyRoundTripper) dialWithHttpProxy(req *http.Request, proxyURL *url.UR
184184

185185
//nolint:staticcheck // SA1019 ignore deprecated httputil.NewProxyClientConn
186186
proxyClientConn := httputil.NewProxyClientConn(proxyDialConn, nil)
187-
_, err = proxyClientConn.Do(&proxyReq)
187+
response, err := proxyClientConn.Do(&proxyReq)
188188
//nolint:staticcheck // SA1019 ignore deprecated httputil.ErrPersistEOF: it might be
189189
// returned from the invocation of proxyClientConn.Do
190190
if err != nil && err != httputil.ErrPersistEOF {
191191
return nil, err
192192
}
193+
if response != nil && response.StatusCode >= 300 || response.StatusCode < 200 {
194+
return nil, fmt.Errorf("CONNECT request to %s returned response: %s", proxyURL.Redacted(), response.Status)
195+
}
193196

194197
rwc, _ := proxyClientConn.Hijack()
195198

0 commit comments

Comments
 (0)