mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 17:35:40 +08:00
http: keep proxy-connection when connect to upstream http proxy. #42
This commit is contained in:
parent
4781e7b472
commit
a2a67df771
@ -231,16 +231,19 @@ func (s *HTTP) Dial(network, addr string) (net.Conn, error) {
|
|||||||
c.SetKeepAlive(true)
|
c.SetKeepAlive(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
rc.Write([]byte("CONNECT " + addr + " HTTP/1.0\r\n"))
|
var buf bytes.Buffer
|
||||||
rc.Write([]byte("Proxy-Connection: close\r\n"))
|
|
||||||
|
buf.Write([]byte("CONNECT " + addr + " HTTP/1.1\r\n"))
|
||||||
|
buf.Write([]byte("Proxy-Connection: Keep-Alive\r\n"))
|
||||||
|
|
||||||
if s.user != "" && s.password != "" {
|
if s.user != "" && s.password != "" {
|
||||||
auth := s.user + ":" + s.password
|
auth := s.user + ":" + s.password
|
||||||
rc.Write([]byte("Proxy-Authorization: Basic " + base64.StdEncoding.EncodeToString([]byte(auth)) + "\r\n"))
|
buf.Write([]byte("Proxy-Authorization: Basic " + base64.StdEncoding.EncodeToString([]byte(auth)) + "\r\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
//header ended
|
//header ended
|
||||||
rc.Write([]byte("\r\n"))
|
buf.Write([]byte("\r\n"))
|
||||||
|
rc.Write(buf.Bytes())
|
||||||
|
|
||||||
respR := bufio.NewReader(rc)
|
respR := bufio.NewReader(rc)
|
||||||
respTP := textproto.NewReader(respR)
|
respTP := textproto.NewReader(respR)
|
||||||
|
Loading…
Reference in New Issue
Block a user