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 terry.reedy
Recipients orsenthil, terry.reedy
Date 2012-11-13.01:57:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1352771853.32.0.535718799021.issue16464@psf.upfronthosting.co.za>
In-reply-to
Content
Code based on python-list post by a do-not-wish-to-register urllib user.

import urllib.request
opener = urllib.request.build_opener()
request = urllib.request.Request("http://example.com/", headers =
        {"Content-Type": "application/x-www-form-urlencoded"})
print(request.data, '\n', request.header_items())

opener.open(request, "1".encode("us-ascii"))
print(request.data, '\n', request.header_items())

opener.open(request, "123456789".encode("us-ascii"))
print(request.data, '\n', request.header_items())
>>> 
None 
 [('Content-type', 'application/x-www-form-urlencoded')]
b'1' 
 [('Content-length', '1'), ('Host', 'example.com'), ('User-agent', 'Python-urllib/3.3'), ('Content-type', 'application/x-www-form-urlencoded')]
b'123456789' 
 [('Content-length', '1'), ('Host', 'example.com'), ('User-agent', 'Python-urllib/3.3'), ('Content-type', 'application/x-www-form-urlencoded')]

The first opener.open adds data and several headers to request, including content-length. The second changes the data but not the content-length. The docs do not say anything about this either way.
History
Date User Action Args
2012-11-13 01:57:33terry.reedysetrecipients: + terry.reedy, orsenthil
2012-11-13 01:57:33terry.reedysetmessageid: <1352771853.32.0.535718799021.issue16464@psf.upfronthosting.co.za>
2012-11-13 01:57:33terry.reedylinkissue16464 messages
2012-11-13 01:57:32terry.reedycreate