[New-bugs-announce] [issue38831] urllib.request header characters being changed to lowercase

rosoroso report at bugs.python.org
Sun Nov 17 09:38:15 EST 2019


New submission from rosoroso <robert.calvert at ibm.com>:

When using the urllib request headers, I've found that certain letters are converted to their lowercase versions whilst part of a request object (H->h in the example, see at bottom).
Whilst this should not usually be an issue (Since headers are not supposed to be case sensitive), I've found an API for which that is not the case.

Options for fixing this could include, not changing the case of characters in header fields or updating the docs to include a warning of this behaviour (https://docs.python.org/3/library/urllib.request.html)

import urllib.request
header = {"Test-Header":"Value"}
requestobject = urllib.request.Request("https://www.example.com",None,header)
print ("Original header is:", header)
print ("Request header is:", requestobject.header_items())

'''
Orginal header is: {'Test-Header': 'Value'}
Request header is: [('Test-header', 'Value')]
Version was Python 3.6.5
'''

----------
messages: 356813
nosy: rosoroso
priority: normal
severity: normal
status: open
title: urllib.request header characters being changed to lowercase
type: behavior
versions: Python 3.6

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


More information about the New-bugs-announce mailing list