Bugs: Content-Length not updated by reused urllib.request.Request / has_header() case-sensitive

Terry Reedy tjreedy at udel.edu
Tue Nov 27 18:24:12 EST 2012


On 11/12/2012 8:58 PM, Terry Reedy wrote:
> On 11/12/2012 4:35 PM, Terry Reedy wrote:
>>> import urllib.request
>> opener = urllib.request.build_opener()
>> request = urllib.request.Request("http://example.com/", headers =
>> {"Content-Type": "application/x-www-form-urlencoded"})
>>>> 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())
>>>> exhibits the same behavior in 3.3.0 of printing ('Content-length', '1')
>> in the last output. I agree that that looks wrong, but I do not know if
>> such re-use is supposed to be supported.
>> I opened http://bugs.python.org/issue16464

A patch has been written by Alexey Kachayev and pushed by Andrew Svetlov 
and the behavior will change in 3.4.0 to allow reuse.
-- 
Terry Jan Reedy


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /