#17485: Delete the Content-Length header if the data attribute is deleted.

This is a follow on to issue 16464.  Original patch by Daniel Wozniak.
This commit is contained in:
R David Murray 2013-03-20 00:10:51 -04:00
parent d5a6e25470
commit 9cc7d45571
4 changed files with 16 additions and 3 deletions

View File

@ -1488,11 +1488,20 @@ class RequestTests(unittest.TestCase):
# if we change data we need to remove content-length header
# (cause it's most probably calculated for previous value)
def test_setting_data_should_remove_content_length(self):
self.assertFalse("Content-length" in self.get.unredirected_hdrs)
self.assertNotIn("Content-length", self.get.unredirected_hdrs)
self.get.add_unredirected_header("Content-length", 42)
self.assertEqual(42, self.get.unredirected_hdrs["Content-length"])
self.get.data = "spam"
self.assertFalse("Content-length" in self.get.unredirected_hdrs)
self.assertNotIn("Content-length", self.get.unredirected_hdrs)
# issue 17485 same for deleting data.
def test_deleting_data_should_remove_content_length(self):
self.assertNotIn("Content-length", self.get.unredirected_hdrs)
self.get.data = 'foo'
self.get.add_unredirected_header("Content-length", 3)
self.assertEqual(3, self.get.unredirected_hdrs["Content-length"])
del self.get.data
self.assertNotIn("Content-length", self.get.unredirected_hdrs)
def test_get_full_url(self):
self.assertEqual("http://www.python.org/~jeremy/",

View File

@ -296,7 +296,7 @@ class Request:
@data.deleter
def data(self):
self._data = None
self.data = None
def _parse(self):
self.type, rest = splittype(self.full_url)

View File

@ -1341,6 +1341,7 @@ Steven Work
Gordon Worley
Darren Worrall
Thomas Wouters
Daniel Wozniak
Heiko Wundram
Doug Wyatt
Robert Xiao

View File

@ -292,6 +292,9 @@ Core and Builtins
Library
-------
- Issue #17485: Also delete the Request Content-Length header if the data
attribute is deleted. (Follow on to issue 16464).
- Issue #15927: CVS now correctly parses escaped newlines and carriage
when parsing with quoting turned off.