python-proxy icon indicating copy to clipboard operation
python-proxy copied to clipboard

Obey RFC2616 in CONNECT request

Open Mervent opened this issue 3 years ago • 1 comments

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--

Mervent avatar Mar 16 '22 18:03 Mervent

Proper usage of CONNECT method is also described in updated RFC7231 https://httpwg.org/specs/rfc7231.html#CONNECT

Mervent avatar Mar 17 '22 17:03 Mervent