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

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

Issue 16037: httplib: header parsing is not delimited
Patch Set: Created 5 years, 10 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
« Lib/http/client.py ('K') | « Lib/http/client.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 errno 1 import errno
2 from http import client 2 from http import client
3 import io 3 import io
4 import os 4 import os
5 import array 5 import array
6 import socket 6 import socket
7 7
8 import unittest 8 import unittest
9 TestCase = unittest.TestCase 9 TestCase = unittest.TestCase
10 10
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 # from a HEAD request. (Tickles SF bug #622042.) 264 # from a HEAD request. (Tickles SF bug #622042.)
265 sock = FakeSocket( 265 sock = FakeSocket(
266 'HTTP/1.1 200 OK\r\n' 266 'HTTP/1.1 200 OK\r\n'
267 'Content-Length: 14432\r\n' 267 'Content-Length: 14432\r\n'
268 '\r\n', 268 '\r\n',
269 NoEOFStringIO) 269 NoEOFStringIO)
270 resp = client.HTTPResponse(sock, method="HEAD") 270 resp = client.HTTPResponse(sock, method="HEAD")
271 resp.begin() 271 resp.begin()
272 if resp.read(): 272 if resp.read():
273 self.fail("Did not expect response from HEAD request") 273 self.fail("Did not expect response from HEAD request")
274
275 def test_too_many_headers(self):
276 headers = '\r\n'.join('Header%d: foo' % i for i in range(200)) + '\r\n'
277 text = ('HTTP/1.1 200 OK\r\n' + headers)
278 s = FakeSocket(text)
279 r = client.HTTPResponse(s)
280 self.assertRaises(client.TooManyHeaders, r.begin)
274 281
275 def test_send_file(self): 282 def test_send_file(self):
276 expected = (b'GET /foo HTTP/1.1\r\nHost: example.com\r\n' 283 expected = (b'GET /foo HTTP/1.1\r\nHost: example.com\r\n'
277 b'Accept-Encoding: identity\r\nContent-Length:') 284 b'Accept-Encoding: identity\r\nContent-Length:')
278 285
279 with open(__file__, 'rb') as body: 286 with open(__file__, 'rb') as body:
280 conn = client.HTTPConnection('example.com') 287 conn = client.HTTPConnection('example.com')
281 sock = FakeSocket(body) 288 sock = FakeSocket(body)
282 conn.sock = sock 289 conn.sock = sock
283 conn.request('GET', '/foo', body) 290 conn.request('GET', '/foo', body)
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 header = self.resp.getheader('No-Such-Header',default=42) 756 header = self.resp.getheader('No-Such-Header',default=42)
750 self.assertEqual(header, 42) 757 self.assertEqual(header, 42)
751 758
752 def test_main(verbose=None): 759 def test_main(verbose=None):
753 support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest, 760 support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest,
754 HTTPSTest, RequestBodyTest, SourceAddressTest, 761 HTTPSTest, RequestBodyTest, SourceAddressTest,
755 HTTPResponseTest) 762 HTTPResponseTest)
756 763
757 if __name__ == '__main__': 764 if __name__ == '__main__':
758 test_main() 765 test_main()
OLDNEW
« Lib/http/client.py ('K') | « Lib/http/client.py ('k') | no next file » | no next file with comments »

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