diff options
author | Christian Heimes <christian@cheimes.de> | 2008-02-24 13:08:18 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-02-24 13:08:18 (GMT) |
commit | a612dc02ced728f553dcc91ca557a2a8b7fa0ca6 (patch) | |
tree | 62b717da0813ba63b61537d380ea923a1e657b3d /Lib/test/test_httplib.py | |
parent | 8e21a3cf059aa8195716f6e7d3bfd0602daca6f1 (diff) | |
download | cpython-a612dc02ced728f553dcc91ca557a2a8b7fa0ca6.zip cpython-a612dc02ced728f553dcc91ca557a2a8b7fa0ca6.tar.gz cpython-a612dc02ced728f553dcc91ca557a2a8b7fa0ca6.tar.bz2 |
Merged revisions 61034-61036,61038-61048 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61034 | georg.brandl | 2008-02-24 01:03:22 +0100 (Sun, 24 Feb 2008) | 4 lines
#900744: If an invalid chunked-encoding header is sent by a server,
httplib will now raise IncompleteRead and close the connection instead
of raising ValueError.
........
r61035 | georg.brandl | 2008-02-24 01:14:24 +0100 (Sun, 24 Feb 2008) | 2 lines
#1627: httplib now ignores negative Content-Length headers.
........
r61039 | andrew.kuchling | 2008-02-24 03:39:15 +0100 (Sun, 24 Feb 2008) | 1 line
Remove stray word
........
r61040 | neal.norwitz | 2008-02-24 03:40:58 +0100 (Sun, 24 Feb 2008) | 3 lines
Add a little info to the 3k deprecation warnings about what to use instead.
Suggested by Raymond Hettinger.
........
r61041 | facundo.batista | 2008-02-24 04:17:21 +0100 (Sun, 24 Feb 2008) | 4 lines
Issue 1742669. Now %d accepts very big float numbers.
Thanks Gabriel Genellina.
........
r61046 | neal.norwitz | 2008-02-24 08:21:56 +0100 (Sun, 24 Feb 2008) | 5 lines
Get ctypes working on the Alpha (Tru64). The problem was that there
were two module_methods and the one used depended on the order the
modules were loaded. By making the test module_methods static,
it is not exported and the correct version is picked up.
........
r61048 | neal.norwitz | 2008-02-24 09:27:49 +0100 (Sun, 24 Feb 2008) | 1 line
Fix typo of hexidecimal
........
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r-- | Lib/test/test_httplib.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 4caf996..ca801da 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -159,6 +159,42 @@ class BasicTest(TestCase): self.assertTrue(sock.data.startswith(expected), '%r != %r' % (sock.data[:len(expected)], expected)) + def test_chunked(self): + chunked_start = ( + 'HTTP/1.1 200 OK\r\n' + 'Transfer-Encoding: chunked\r\n\r\n' + 'a\r\n' + 'hello worl\r\n' + '1\r\n' + 'd\r\n' + ) + sock = FakeSocket(chunked_start + '0\r\n') + resp = httplib.HTTPResponse(sock, method="GET") + resp.begin() + self.assertEquals(resp.read(), b'hello world') + resp.close() + + for x in ('', 'foo\r\n'): + sock = FakeSocket(chunked_start + x) + resp = httplib.HTTPResponse(sock, method="GET") + resp.begin() + try: + resp.read() + except httplib.IncompleteRead as i: + self.assertEquals(i.partial, b'hello world') + else: + self.fail('IncompleteRead expected') + finally: + resp.close() + + def test_negative_content_length(self): + sock = FakeSocket('HTTP/1.1 200 OK\r\nContent-Length: -1\r\n\r\nHello\r\n') + resp = httplib.HTTPResponse(sock, method="GET") + resp.begin() + self.assertEquals(resp.read(), b'Hello\r\n') + resp.close() + + class OfflineTest(TestCase): def test_responses(self): self.assertEquals(httplib.responses[httplib.NOT_FOUND], "Not Found") |