@@ -14,21 +14,26 @@ import (
1414 "strings"
1515)
1616
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+ }
1821
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 )
2124}
2225
2326func init () {
2427 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
2630 })
2731}
2832
2933type httpProxyDialer struct {
3034 proxyURL * url.URL
3135 forwardDial func (network , addr string ) (net.Conn , error )
36+ proxyHeader http.Header
3237}
3338
3439func (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)
4752 }
4853 }
4954
55+ for k , v := range hpd .proxyHeader {
56+ connectHeader [k ] = v
57+ }
58+
5059 connectReq := & http.Request {
5160 Method : "CONNECT" ,
5261 URL : & url.URL {Opaque : addr },
0 commit comments