-
Notifications
You must be signed in to change notification settings - Fork 983
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
Using proxy may break middleware parsers #733
Comments
Hi @graudeejs, I'll need some additional information, can you please provide all the output coming from the |
I've just noticed, that this happens only for first request. 2nd request will be fine. And that's logical, because Faraday apparently expects headers right after status 200, but in this case after status 200 (Connection established [to proxy]), there's another status 200. On next request, connection to proxy is already established, so everything works as expected @iMacTia here's gist with yaml of first and second response: https://gist.github.com/graudeejs/d9d08f1a5a8f6595d46f44cd1e3ebaa8 P.S. |
Oh and logger info:
Second request:
|
Here's what happens when you make same request with curl throught proxy:
Notice first HTTP/1.1 200 Connection established - this means that curl/faraday connected to proxy. |
Thanks @graudeejs, that should allow me to reproduce. |
@iMacTia Good point. The issue with Net::HTTP is that it uses god know what kind of ssl CA bundle. require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE The result is that it works correctly: I had one request via proxy and it was parsed correctly. |
Mmmmh that helps at least. I believe something is wrong with headers returned by Patron gem. |
I don't really need to proxy my requests. I wanted to use mitmproxy to have better insight of what's actually going on while developing client for API. |
Hi @graudeejs, I've tried replicating this issue locally but unfortunately I wasn't able to do it. I'll now try with mitmproxy and see what happens |
Hi @graudeejs, update on this. If you look at the method implementation, here is what happens:
The issue is that in case of a Proxy response, the first line after the HTTP status is a blank line, causing the loop to exit immediately and returning an empty headers hash. This behaviour is even more complicated by the fact that different versions of CURL behaves differently. In fact, I initially had issues reproducing your issue because it works on one of my computers but not in the other. I'm really sorry for taking so long to find out, but I believe you want to open this same issue on If you need any additional information, feel free to ask. |
@iMacTia thanks for the investigation, the fix should be applied once the linked PR is merged to Patron master. |
@julik thanks for the update! |
I've setup mitmproxy to listen on port 8080
The result isn't parsed. In my opinion that's because when you proxy a request something like this is returned
Note the extra
HTTP/1.1 200 Connection established
Disabling proxy works as expected and I get parsed body.
Note that I'm using patron, because it's using system ssl certificates.
The text was updated successfully, but these errors were encountered: