[issue38831] urllib.request header characters being changed to lowercase

Eric V. Smith report at bugs.python.org
Sun Nov 17 13:04:25 EST 2019


Eric V. Smith <eric at trueblade.com> added the comment:

Well, the standard says they're case insensitive: https://tools.ietf.org/html/rfc7230#section-3.2

Forcing the case on the header item seems quite deliberate: https://github.com/python/cpython/blob/master/Lib/urllib/request.py#L399
I assume that the .capitalize call is made in order to normalize headers, in case another header with the same name but different capitalization is added.

I can't recommend making a code change here. We're compliant with the standard, and any change would no doubt break someone's code.

I do agree that it might be worth documenting.

It's unfortunate that the caller can't specify an exact string they want to use (in order to handle broken servers), but that's the way it's been for ages.

----------
nosy: +eric.smith

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38831>
_______________________________________


More information about the Python-bugs-list mailing list