Comments (4)
Currently httplib coerces headers into a dict, which breaks some things
Well, to be precise the problem is not dict itself but merging headers with the same name into one entry.
It's worth noting it was fixed in Python 3:
2.7.2
>>> import httplib
>>> conn = httplib.HTTPConnection('www.wp.pl')
>>> conn.request('HEAD', '/index.html')
>>> res = conn.getresponse()
>>> print res.getheaders()
[('set-cookie', 'reksticket=1323027255; expires=Tuesday, 06-Dec-11 19:34:15 GMT; path=/; domain=.www.wp.pl,
rekticket=1323027255; expires=Tuesday, 06-Dec-11 19:34:15 GMT; path=/; domain=.wp.pl,
statid=77.255.32.195.20351:1323027255:2355453207:v1; path=/; expires=Wed, 03-Dec-14 19:34:15 GMT,
statid=77.255.32.195.20351:1323027255:2355453207:v1; domain=.wp.pl; path=/; expires=Wed, 03-Dec-14 19:34:15 GMT'),...]
3.2.2
>>> from http import client
>>> conn = client.HTTPConnection('www.wp.pl')
>>> conn.request('HEAD', '/index.html')
>>> res = conn.getresponse()
>>> print(res.getheaders())
[('Set-Cookie', 'reksticket=1323028283; expires=Tuesday, 06-Dec-11 19:51:23 GMT; path=/; domain=.www.wp.pl'), ('Set-Cookie',
'rekticket=1323028283; expires=Tuesday, 06-Dec-11 19:51:23 GMT; path=/; domain=.wp.pl'), ('Set-Cookie',
'statid=77.255.32.195.7252:1323028283:2993994873:v1; path=/; expires=Wed, 03-Dec-14 19:51:23 GMT'), ('Set-Cookie',
'statid=77.255.32.195.7252:1323028283:2993994873:v1; domain=.wp.pl; path=/; expires=Wed, 03-Dec-14 19:51:23 GMT'), ...]
This functionality is provided by (undocumented?) HTTPMessage
class and Python issue 4773 HTTPMessage not documented and has inconsistent API across 2.6/3.0 is of interest here. The difference shown above is noted by Joel Verhagen in comment http://bugs.python.org/issue4773#msg154781.
The issue we see was raised as issue 1660009 continuing problem with httplib multiple set-cookie headers Python issue.
John J Lee suggests using getallmatchingheaders()
method or headers
property of rfc822.Message
class to get raw header data.
from urllib3.
@piotr-dobrogost Thanks for doing the research and posting an update of the current state. The 3.2.2 thing is very interesting.
Maybe we can punt this issue to "someday when we fork for 3.x" like the rest. :P I'll open a py3 issue to track these things.
from urllib3.
Just FYI. It is not totally an issue. It is subtle.
https://github.com/kennethreitz/requests/issues/741#issuecomment-7293231
from urllib3.
We have HTTPHeaderDict
now, I think it satisfies this.
from urllib3.
Related Issues (20)
- All Retry backoff_factor to optionally start applying from first retry HOT 4
- Retry backoff_factor offset from second retry incorrectly computed HOT 2
- HTTPConnection.request chunked=False doesn't work properly HOT 8
- Need to exception for "SSLEOFError" on python 3.10, 3.11, 3.12 HOT 3
- After upgrading to 2.2.1: 'HTTPResponse' object has no attribute 'json' HOT 1
- Comment typo settimout settimeout HOT 1
- Dependency management issue HOT 2
- Fix test_redirecting_to_bad_url failure in Requests HOT 12
- NodeJS + pyodide support HOT 1
- Retry.respect_retry_after_header=False is not honored when retry is incremented HOT 1
- Unable to build the doc `Command sphinx-build -b html -W . _build/html failed with exit code 2` HOT 1
- Sunsetting official support for Python 2
- Change log for version 1.26.19
- publish.yml uses two different versions of actions/download-artifact HOT 1
- requests > 2.31 - TypeError: unhashable type: 'list'
- pyproject.toml specifies an illegal value in the "dynamic" field HOT 4
- Cannot pass host parameter to PoolManager HOT 1
- v2.0.5 is tagged strangely HOT 1
- Add support for HTTP/2 chunked request bodies HOT 1
- why this happens ?? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from urllib3.