Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPS requests with proxy broken, because HTTP status line include full URL #2810

Closed
datakurre opened this issue Mar 7, 2018 · 2 comments
Closed
Labels

Comments

@datakurre
Copy link

Long story short

When I used aiohttp with proxy to fetch https resource, I always got only the front page of the requested domain, because aiohttp wrongly included domain in the eventual get request.

Expected behaviour

CONNECT example.com:443 HTTP/1.1
Host: example.com
Accept-Encoding: gzip, deflate
User-Agent: Python/3.6 aiohttp/3.0.1
GET /some/path HTTP/1.1
Accept-Encoding: gzip, deflate
Host: example.com
User-Agent: Python/3.6 aiohttp/3.0.1

Actual behaviour

CONNECT example.com:443 HTTP/1.1
Host: example.com
Accept-Encoding: gzip, deflate
User-Agent: Python/3.6 aiohttp/3.0.1
GET https://example.com/some/path HTTP/1.1
Accept-Encoding: gzip, deflate
Host: example.com
User-Agent: Python/3.6 aiohttp/3.0.1

I located the issue to this commit:

3f283c6

And patched it locally with:

diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py
index 33bd25ca..31c0ce93 100644
--- a/aiohttp/client_reqrep.py
+++ b/aiohttp/client_reqrep.py
@@ -472,7 +472,7 @@ class ClientRequest:
         # - most common is origin form URI
         if self.method == hdrs.METH_CONNECT:
             path = '{}:{}'.format(self.url.raw_host, self.url.port)
-        elif self.proxy and not self.ssl:
+        elif self.proxy and not self.ssl and not self.url.scheme == 'https':
             path = str(self.url)
         else:
             path = self.url.raw_path

Not sure what would be the optimal test to separate proxied http requests from proxied https requests.

@asvetlov
Copy link
Member

asvetlov commented Mar 8, 2018

Should be fixed by 7b400d7
My bad

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants