@@ -14,21 +14,29 @@ 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 , ok := forwardDialer .(* netDialer )
29+ if ! ok {
30+ return nil , errors .New ("type assertion failed when ini proxy info" )
31+ }
32+ return & httpProxyDialer {proxyURL : proxyURL , forwardDial : forwardDialer .Dial , proxyHeader : p .proxyHeader }, nil
2633 })
2734}
2835
2936type httpProxyDialer struct {
3037 proxyURL * url.URL
3138 forwardDial func (network , addr string ) (net.Conn , error )
39+ proxyHeader http.Header
3240}
3341
3442func (hpd * httpProxyDialer ) Dial (network string , addr string ) (net.Conn , error ) {
@@ -47,6 +55,10 @@ func (hpd *httpProxyDialer) Dial(network string, addr string) (net.Conn, error)
4755 }
4856 }
4957
58+ for k , v := range hpd .proxyHeader {
59+ connectHeader [k ] = v
60+ }
61+
5062 connectReq := & http.Request {
5163 Method : "CONNECT" ,
5264 URL : & url.URL {Opaque : addr },
0 commit comments