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
Setting http_proxy breaks HTTPretty #122
Comments
I just ran into this problem as well. Looks like requests does the proxy handling so it might be hard to work around it at the socket level. Maybe httpretty could detect if a proxy is being used and rewrite requests to the proxy url to the url given in the http metadata? |
I also encountered this problem and found that I can workaround it by ignoring the host name in the registered URL. For example, change the full URL:
to the following regular expression:
|
Interesting, looks like a nice bug to kill, would you give me example code of how to reproduce? |
Given the following simple unit test:
we can see that it passes when the http proxy environment variable is not set:
but it fails when the http proxy environment variable is set to a valid proxy server:
The test has failed because the real HTTP request has completed successfully instead of being intercepted by httpretty. Note that this example requires a local proxy server running on port 8888. I am using OWASP ZAP as an HTTP debugging proxy. |
previously this would fail: http_proxy=http://foo.bar make test now it will pass. This works around a bug where httpretty is not able to patch http operations if http_proxy is set. gabrielfalcao/HTTPretty#122
previously this would fail: http_proxy=http://foo.bar make test now it will pass. This works around a bug where httpretty is not able to patch http operations if http_proxy is set. gabrielfalcao/HTTPretty#122
I just ran into a similar issue. It /seems/ like issues related to proxies can be encountered with at least a couple different paths:
Unfortunately, the only not-so-ugly workaround that I can think of offhand to get around this is to simply not use proxies when tunneling. An ugly workaround might be to mock out httplib's HTTPConnect.sendall, intercepting CONNECT calls and appending an additional CRLF to them. |
…ty#122) http_proxy environment variable will be unset during unittests.
Have we made any progress on the issue? If not, we could at least make the docs mention that proxies should not be used. What do you think? |
A work around is to disable proxy within the process
from what I found when happy to share more detailed notes with anyone that wants to tackle this -- most of my investigation revolved around |
Save the code below in
proxy_test.py
:The code works when run without
http_proxy
set but breaks when that variable is set. In the later case a real HTTP request is sent via the proxy.The text was updated successfully, but these errors were encountered: