python-proxy
python-proxy copied to clipboard
Obey RFC2616 in CONNECT request
Some proxy servers requires Host header to be the same as CONNECT or they will return 400 http code on request.
RFC2616 tells us the same thing
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
An HTTP/1.1 proxy MUST ensure that any request message it forwards does contain an appropriate Host header field that >identifies the service being requested by the proxy. All Internet-based HTTP/1.1 servers MUST respond with a 400 (Bad >Request) status code to any HTTP/1.1 request message which lacks a Host header field.
Before the change
CONNECT ifconfig.co:443 HTTP/1.1
Host: PROXY_IP
Proxy-Authorization: Basic --base64data--
After the change
CONNECT ifconfig.co:443 HTTP/1.1
Host: ifconfig.co:443
Proxy-Authorization: Basic --base64data--
Proper usage of CONNECT method is also described in updated RFC7231 https://httpwg.org/specs/rfc7231.html#CONNECT