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
reconnect issues via CONNECT proxies #366
Comments
Have you looked at some of the proxy-related tests in test_socketlevel.py? (We need to break that up into smaller pieces so that it's more discoverable.) Could you expand on why |
In order to make connections retunnel properly, you'd have to modify or monkeypatch httplib |
Sadness. :( If you could find a way to write a test which illustrates the broken behaviour, that will definitely help move this along. Should be doable with the socketlevel suite we have. |
test_socketlevel.py doesn't test CONNECT at all. But since there are working tests for SSL, I might be able to cobble something together. |
I added a test to test_socketlevel.py. The test (TestProxyManager.test_connect_reconn) uses retries=0 because it seems that in a pure urllib3 environment, retries eventually do reconnect to the proxy, so at least part of my problem is requests aborting the first time it sees a socket.error when proxying. urllib3 still does have a problem, since it does try to connect to the origin server at least once. (run the test with retries=1 and a tcpdump looking at port 443 on the loopback interface) |
@cg2v That looks like a sensible starting point, thanks for making that effort! Would you like to migrate this conversation into a PR around that test case? |
i believe this is the real issue behind #295, glad someone has a reproducible test case now |
What should the pull request contain? I don't see how it makes sense to submit a PR that will result in the tests failing. |
To start, just the failing tests of the desired behaviour. :) Following, ideally fixes for this behaviours from you or somebody else. We'll probably avoid merging the PR (or any forks of it) until it passes, though. |
Ah interesting. I see a similar issue using
|
#369 is fixing this issue 👍 |
I assume #369 fixed this. Let me know if this needs to be reopened. :) |
if I connect to an https server via a CONNECT proxy (ProxyManager), and either the origin server or the proxy disconnects, then subsequent requests connect directly to the origin server and attempt to use it as a proxy. This is because the first time httplib.HTTPConnection._tunnel() is called, it changes the .host and .port to be the origin server's.
I have a patch that fixes this for me, but I don't think I will be able to produce a test case that tests for this issue.
Two changes are required, and there is another that I think makes sense.
Assuming you have a functioning proxy (for testing, I set up a simple proxy on apache on localhost), the following script should fail:
p=ProxyManager(proxy_url="http://somewhere")
r=p.request('GET', 'https://api.box.com/', redirect=False, headers={'Connection':'close'})
r=p.request('GET', 'https://api.box.com/', redirect=False, headers={'Connection':'close'})
(my real code uses requests, and I'm not sure that this simple test will fail in all the same cases as my requesrs code)
The text was updated successfully, but these errors were encountered: