@@ -14,21 +14,26 @@ import (
14
14
"strings"
15
15
)
16
16
17
- type netDialerFunc func (network , addr string ) (net.Conn , error )
17
+ type netDialer struct {
18
+ proxyHeader http.Header
19
+ f func (network , addr string ) (net.Conn , error )
20
+ }
18
21
19
- func (fn netDialerFunc ) Dial (network , addr string ) (net.Conn , error ) {
20
- return fn (network , addr )
22
+ func (n netDialer ) Dial (network , addr string ) (net.Conn , error ) {
23
+ return n . f (network , addr )
21
24
}
22
25
23
26
func init () {
24
27
proxy_RegisterDialerType ("http" , func (proxyURL * url.URL , forwardDialer proxy_Dialer ) (proxy_Dialer , error ) {
25
- return & httpProxyDialer {proxyURL : proxyURL , forwardDial : forwardDialer .Dial }, nil
28
+ p , _ := forwardDialer .(* netDialer )
29
+ return & httpProxyDialer {proxyURL : proxyURL , forwardDial : forwardDialer .Dial , proxyHeader : p .proxyHeader }, nil
26
30
})
27
31
}
28
32
29
33
type httpProxyDialer struct {
30
34
proxyURL * url.URL
31
35
forwardDial func (network , addr string ) (net.Conn , error )
36
+ proxyHeader http.Header
32
37
}
33
38
34
39
func (hpd * httpProxyDialer ) Dial (network string , addr string ) (net.Conn , error ) {
@@ -47,6 +52,10 @@ func (hpd *httpProxyDialer) Dial(network string, addr string) (net.Conn, error)
47
52
}
48
53
}
49
54
55
+ for k , v := range hpd .proxyHeader {
56
+ connectHeader [k ] = v
57
+ }
58
+
50
59
connectReq := & http.Request {
51
60
Method : "CONNECT" ,
52
61
URL : & url.URL {Opaque : addr },
0 commit comments