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

Terry Reedy tjreedy at udel.edu
Tue Nov 13 02:58:47 CET 2012


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

-- 
Terry Jan Reedy



More information about the Python-list mailing list