Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(182987)

Side by Side Diff: Lib/test/test_httplib.py

Issue 16037: httplib: header parsing is not delimited
Patch Set: Created 4 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/httplib.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import httplib 1 import httplib
2 import array 2 import array
3 import httplib 3 import httplib
4 import StringIO 4 import StringIO
5 import socket 5 import socket
6 import errno 6 import errno
7 7
8 import unittest 8 import unittest
9 TestCase = unittest.TestCase 9 TestCase = unittest.TestCase
10 10
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 # from a HEAD request. (Tickles SF bug #622042.) 254 # from a HEAD request. (Tickles SF bug #622042.)
255 sock = FakeSocket( 255 sock = FakeSocket(
256 'HTTP/1.1 200 OK\r\n' 256 'HTTP/1.1 200 OK\r\n'
257 'Content-Length: 14432\r\n' 257 'Content-Length: 14432\r\n'
258 '\r\n', 258 '\r\n',
259 NoEOFStringIO) 259 NoEOFStringIO)
260 resp = httplib.HTTPResponse(sock, method="HEAD") 260 resp = httplib.HTTPResponse(sock, method="HEAD")
261 resp.begin() 261 resp.begin()
262 if resp.read() != "": 262 if resp.read() != "":
263 self.fail("Did not expect response from HEAD request") 263 self.fail("Did not expect response from HEAD request")
264
265 def test_too_many_headers(self):
266 headers = '\r\n'.join('Header%d: foo' % i for i in xrange(200)) + '\r\n'
267 text = ('HTTP/1.1 200 OK\r\n' + headers)
268 s = FakeSocket(text)
269 r = httplib.HTTPResponse(s)
270 self.assertRaises(httplib.HTTPException, r.begin)
264 271
265 def test_send_file(self): 272 def test_send_file(self):
266 expected = 'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \ 273 expected = 'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \
267 'Accept-Encoding: identity\r\nContent-Length:' 274 'Accept-Encoding: identity\r\nContent-Length:'
268 275
269 body = open(__file__, 'rb') 276 body = open(__file__, 'rb')
270 conn = httplib.HTTPConnection('example.com') 277 conn = httplib.HTTPConnection('example.com')
271 sock = FakeSocket(body) 278 sock = FakeSocket(body)
272 conn.sock = sock 279 conn.sock = sock
273 conn.request('GET', '/foo', body) 280 conn.request('GET', '/foo', body)
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 self.assertTrue('CONNECT destination.com' in conn.sock.data) 576 self.assertTrue('CONNECT destination.com' in conn.sock.data)
570 self.assertTrue('Host: destination.com' in conn.sock.data) 577 self.assertTrue('Host: destination.com' in conn.sock.data)
571 578
572 579
573 def test_main(verbose=None): 580 def test_main(verbose=None):
574 test_support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest, 581 test_support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest,
575 HTTPSTimeoutTest, SourceAddressTest, TunnelTests) 582 HTTPSTimeoutTest, SourceAddressTest, TunnelTests)
576 583
577 if __name__ == '__main__': 584 if __name__ == '__main__':
578 test_main() 585 test_main()
OLDNEW
« no previous file with comments | « Lib/httplib.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+