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

ProxyConnector doesn't always set correct request line #368

Closed
strayer opened this issue May 18, 2015 · 4 comments
Closed

ProxyConnector doesn't always set correct request line #368

strayer opened this issue May 18, 2015 · 4 comments
Labels

Comments

@strayer
Copy link

strayer commented May 18, 2015

I tried using aiohttp with a HTTP proxy and ran into several problems. Most proxies simply broke and told me the client made a malformed request, some other notified me that I need to enable transparent proxy support.

I think this is because the correct request line is only set when the first connection to the proxy is made.

The relevant code to update the request line for the proxy should be here: https://github.com/KeepSafe/aiohttp/blob/master/aiohttp/connector.py#L523

_create_connection seems to be called in BaseConnector.connect, which is only used in ClientSession.request, if I understand the code correctly.

If you look at the source of BaseConnector.connect you can see that _create_connection is only called as long as there is no existing connection - thus request that reuse an existing connection don't get an updated request line and will fail, as long as the HTTP proxy doesn't have transparent proxy support.

This also happens when reusing the same ProxyConnector for multiple requests, even if not using a Session object, since the connection to the proxy is stored in the Connector.

@asvetlov
Copy link
Member

Hmm. Would you try ProxyConnector(proxy_addr, force_close=True)?
I'm inclined to use force_close=True as default value for ProxyConnector.

@strayer
Copy link
Author

strayer commented May 18, 2015

Seems to work... using a request session like this:

PROXY_CONNECTOR = aiohttp.ProxyConnector(proxy="http://127.0.0.1:12345", force_close=True)
SESSION = aiohttp.ClientSession(connector=PROXY_CONNECTOR)

SESSION.get(...)

asvetlov added a commit that referenced this issue May 18, 2015
…g from now #368

Add connector.force_close property
@asvetlov
Copy link
Member

Fixed in 792b980 -- force_close=True by default for ProxyConnector

@lock
Copy link

lock bot commented Oct 29, 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.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 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