Skip to content

Commit 25c6c2a

Browse files
committed
Fixes nil proxy url behavior
1 parent fd579db commit 25c6c2a

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,9 @@ func (d *Dialer) proxyNetDial(req *http.Request, netDial netDialerFunc) (netDial
426426
if err != nil {
427427
return nil, err
428428
}
429+
// Request should not be proxied; use originial dial function.
429430
if proxyURL == nil {
430-
return nil, errors.New("generated proxy url is nil")
431+
return netDial, nil
431432
}
432433
if proxyURL.Scheme == "http" && d.NetDialTLSContext != nil {
433434
return nil, errors.New("dial TLS function set for dialing non-HTTPS proxy")

client_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ func TestProxyNetDialErrors(t *testing.T) {
4646
proxyFn: nil,
4747
errorMsg: "proxy url function is nil",
4848
},
49-
"proxy generating nil URL is error": {
50-
proxyFn: func(req *http.Request) (*url.URL, error) {
51-
return nil, nil
52-
},
53-
errorMsg: "generated proxy url is nil",
54-
},
5549
"proxy URL generator returning error is error": {
5650
proxyFn: func(req *http.Request) (*url.URL, error) {
5751
return nil, errors.New("error generating proxy url")

0 commit comments

Comments
 (0)