Message175485
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. |
|
Date |
User |
Action |
Args |
2012-11-13 01:57:33 | terry.reedy | set | recipients:
+ terry.reedy, orsenthil |
2012-11-13 01:57:33 | terry.reedy | set | messageid: <1352771853.32.0.535718799021.issue16464@psf.upfronthosting.co.za> |
2012-11-13 01:57:33 | terry.reedy | link | issue16464 messages |
2012-11-13 01:57:32 | terry.reedy | create | |
|