This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ezio.melotti
Recipients ezio.melotti, orsenthil
Date 2017-03-23.22:03:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490306636.78.0.894703905259.issue29891@psf.upfronthosting.co.za>
In-reply-to
Content
urllib.request.Request allows the user to create a request object like:
  req = Request(url, headers={b'Content-Type': b'application/json'})

When calling urlopen(req, data), urllib will check if a 'Content-Type' header is present and fail to recognize b'Content-Type' because it's bytes.
urrlib will therefore add the default Content-Type 'application/x-www-form-urlencoded', and the request will then be sent with both Content-Types.  This will result in difficult-to-debug errors because the server will sometimes pick one and sometimes the other, depending on the order.

urllib should either reject bytes headers, or check for both bytes and strings.  The docs also don't seem to specify that the headers should be strings.
History
Date User Action Args
2017-03-23 22:03:56ezio.melottisetrecipients: + ezio.melotti, orsenthil
2017-03-23 22:03:56ezio.melottisetmessageid: <1490306636.78.0.894703905259.issue29891@psf.upfronthosting.co.za>
2017-03-23 22:03:56ezio.melottilinkissue29891 messages
2017-03-23 22:03:56ezio.melotticreate