[New-bugs-announce] [issue7540] urllib2 request does not update content length after new add_data

Till Maas report at bugs.python.org
Fri Dec 18 16:24:02 CET 2009


New submission from Till Maas <opensource at till.name>:

When I try to reuse a urllib2.Request object with different post data,
the data itself is updated, but the content length is not. Here is a
simple script to reproduce it on Python 2.5 on Fedora 10 and 2.6 on Arch
Linux:

#!/usr/bin/python
# vim: fileencoding=utf8 
# test with:  echo | socat - tcp4-listen:1111,fork
# Demonstrates bad content length of second request, which should be 2
import urllib2
req = urllib2.Request('http://localhost:1111')
req.add_data("1")
urllib2.urlopen(req)
req.add_data("10")
urllib2.urlopen(req)

----------
components: Library (Lib)
messages: 96567
nosy: till
severity: normal
status: open
title: urllib2 request does not update content length after new add_data
type: behavior
versions: Python 2.5, Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7540>
_______________________________________


More information about the New-bugs-announce mailing list