@@ -28,9 +28,9 @@ func (fn netDialerFunc) DialContext(ctx context.Context, network, addr string) (
28
28
return fn (ctx , network , addr )
29
29
}
30
30
31
- func proxyFromURL (proxyURL * url.URL , forwardDial netDialerFunc ) (netDialerFunc , error ) {
31
+ func proxyFromURL (proxyURL * url.URL , forwardDial netDialerFunc , connectHeader http. Header ) (netDialerFunc , error ) {
32
32
if proxyURL .Scheme == "http" || proxyURL .Scheme == "https" {
33
- return (& httpProxyDialer {proxyURL : proxyURL , forwardDial : forwardDial }).DialContext , nil
33
+ return (& httpProxyDialer {proxyURL : proxyURL , forwardDial : forwardDial , proxyConnectHeader : connectHeader }).DialContext , nil
34
34
}
35
35
dialer , err := proxy .FromURL (proxyURL , forwardDial )
36
36
if err != nil {
@@ -45,8 +45,13 @@ func proxyFromURL(proxyURL *url.URL, forwardDial netDialerFunc) (netDialerFunc,
45
45
}
46
46
47
47
type httpProxyDialer struct {
48
- proxyURL * url.URL
49
- forwardDial netDialerFunc
48
+ proxyURL * url.URL
49
+ forwardDial netDialerFunc
50
+ proxyConnectHeader http.Header
51
+ }
52
+
53
+ func (hpd * httpProxyDialer ) Dial (network , addr string ) (net.Conn , error ) {
54
+ return hpd .DialContext (context .Background (), network , addr )
50
55
}
51
56
52
57
func (hpd * httpProxyDialer ) DialContext (ctx context.Context , network string , addr string ) (net.Conn , error ) {
@@ -56,7 +61,11 @@ func (hpd *httpProxyDialer) DialContext(ctx context.Context, network string, add
56
61
return nil , err
57
62
}
58
63
59
- connectHeader := make (http.Header )
64
+ connectHeader := hpd .proxyConnectHeader
65
+ if hpd .proxyConnectHeader == nil {
66
+ connectHeader := make (http.Header )
67
+ }
68
+
60
69
if user := hpd .proxyURL .User ; user != nil {
61
70
proxyUser := user .Username ()
62
71
if proxyPassword , passwordSet := user .Password (); passwordSet {
0 commit comments