-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Urllib3 HTTPHeaderDict and proxy_from_url problem #632
Comments
This is how the author patch that problem, but a patch is a patch, the headers feature become so weird after that patch:
|
Hey, thanks for giving us a pointer but I can't figure out what the problem is. Could you explain what's broken in urllib3 and how you suggest on fixing it? |
The code is quite long so I don't know what is the best way to show you why that happen, so I will try my best. urllib3.PoolManager.urlopen headers= must be headers format from urllib3._collections.HTTPHeaderDict, right, something like { blah blah }
The problem pop: http://pastebin.com/g2mK1CW4 I tried to fix it by replacing
But why that self.headers work with
I did a work arround like this, problem is solved but it is weird:
|
So you're saying import urllib3
http = urllib3.PoolManager()
headers = urllib3._collections.HTTPHeaderDict()
headers.add('Foo', 'bar')
r = http.request('GET', 'http://httpbin.org/headers', headers=headers)
print r.data
""" ->
{
"headers": {
"Accept-Encoding": "identity",
"Foo": "bar",
"Host": "httpbin.org"
}
}
""" Can you reproduce whatever bug you're experiencing with just urllib3 like above? |
Yeah, with your code, i'm using urllib3 newest version 1.10.4 and Python 3.4.3, the error is the same:
|
Ah perfect, thank you. :) That is a bug indeed, then. |
Thank you, i'm waiting for the next release :) |
|
Actually nevermind, it does seem to encode it incorrectly. Investigating. |
Right, looks like we're only using For now, you can pass in headers as dicts or lists of tuples. |
I still get the same problem, I tried this commit: 838d23a
I copy all its content to my _collections.py in my C Python folder. But still:
The way I update my _collection.py is wrong ? |
@cattleyavns See latest comments since then, there's no fix yet for allowing HTTPHeaderDict in requests. You'll need to pass in headers as a dict or list of tuples as a work-around for now. |
Should be fixed by #679, please re-open if not. :) |
Thanks, I will re-open if this problem still exist :) |
It is a little bit redundant if I reexplain this problem, here is my post about that problem include code of the script: http://www.prxbx.com/forums/showthread.php?tid=2188&pid=18453#pid18453
The main thing is if I do any proxy_from_url or ProxyManager too, that problem appear: http://pastebin.com/g2mK1CW4
And if I use HTTPHeaderDict, i cannot use proxy, and if I use self.headers from http.server, I CAN use proxy, but ALL other page without proxy cannot even load.
The only and best possible at this time I found is use self.headers from http.server with proxy and HTTPHeaderDict with normal page:
Code: http://www.prxbx.com/forums/showthread.php?tid=2188&pid=17911#pid17911
Need:
pip install colorama
pip install pyOpenSSL
pip install urllib3
and Python 3.4.2
urllib3 1.10.4
The text was updated successfully, but these errors were encountered: