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

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

Issue 10721: Remove HTTP 0.9 server support
Patch Set: Created 2 years, 2 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/http/server.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 """Unittests for the various HTTPServer modules. 1 """Unittests for the various HTTPServer modules.
2 2
3 Written by Cody A.W. Somerville <cody-somerville@ubuntu.com>, 3 Written by Cody A.W. Somerville <cody-somerville@ubuntu.com>,
4 Josip Dzolonga, and Michael Otteneder for the 2007/08 GHOP contest. 4 Josip Dzolonga, and Michael Otteneder for the 2007/08 GHOP contest.
5 """ 5 """
6 6
7 from http.server import BaseHTTPRequestHandler, HTTPServer, \ 7 from http.server import BaseHTTPRequestHandler, HTTPServer, \
8 SimpleHTTPRequestHandler, CGIHTTPRequestHandler 8 SimpleHTTPRequestHandler, CGIHTTPRequestHandler
9 from http import server 9 from http import server
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 self.con.putrequest('GET', '/') 126 self.con.putrequest('GET', '/')
127 self.con.endheaders() 127 self.con.endheaders()
128 res = self.con.getresponse() 128 res = self.con.getresponse()
129 self.assertEqual(res.status, 400) 129 self.assertEqual(res.status, 400)
130 130
131 def test_version_none_get(self): 131 def test_version_none_get(self):
132 self.con._http_vsn_str = '' 132 self.con._http_vsn_str = ''
133 self.con.putrequest('GET', '/') 133 self.con.putrequest('GET', '/')
134 self.con.endheaders() 134 self.con.endheaders()
135 res = self.con.getresponse() 135 res = self.con.getresponse()
136 self.assertEqual(res.status, 501) 136 self.assertEqual(res.status, 400)
137 137
138 def test_version_none(self): 138 def test_version_none(self):
139 self.con._http_vsn_str = '' 139 self.con._http_vsn_str = ''
140 self.con.putrequest('PUT', '/') 140 self.con.putrequest('PUT', '/')
141 self.con.endheaders() 141 self.con.endheaders()
142 res = self.con.getresponse() 142 res = self.con.getresponse()
143 self.assertEqual(res.status, 400) 143 self.assertEqual(res.status, 400)
144 144
145 def test_version_invalid(self): 145 def test_version_invalid(self):
146 self.con._http_vsn = 99 146 self.con._http_vsn = 99
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n') 484 self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
485 485
486 def test_http_1_0(self): 486 def test_http_1_0(self):
487 result = self.send_typical_request(b'GET / HTTP/1.0\r\n\r\n') 487 result = self.send_typical_request(b'GET / HTTP/1.0\r\n\r\n')
488 self.verify_http_server_response(result[0]) 488 self.verify_http_server_response(result[0])
489 self.verify_expected_headers(result[1:-1]) 489 self.verify_expected_headers(result[1:-1])
490 self.verify_get_called() 490 self.verify_get_called()
491 self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n') 491 self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
492 492
493 def test_http_0_9(self): 493 def test_http_0_9(self):
494 # 0.9 is treated as 1.0 and returns a full response
494 result = self.send_typical_request(b'GET / HTTP/0.9\r\n\r\n') 495 result = self.send_typical_request(b'GET / HTTP/0.9\r\n\r\n')
495 self.assertEqual(len(result), 1) 496 self.verify_http_server_response(result[0])
496 self.assertEqual(result[0], b'<html><body>Data</body></html>\r\n') 497 self.verify_expected_headers(result[1:-1])
497 self.verify_get_called() 498 self.verify_get_called()
499 self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
498 500
499 def test_with_continue_1_0(self): 501 def test_with_continue_1_0(self):
500 result = self.send_typical_request(b'GET / HTTP/1.0\r\nExpect: 100-conti nue\r\n\r\n') 502 result = self.send_typical_request(b'GET / HTTP/1.0\r\nExpect: 100-conti nue\r\n\r\n')
501 self.verify_http_server_response(result[0]) 503 self.verify_http_server_response(result[0])
502 self.verify_expected_headers(result[1:-1]) 504 self.verify_expected_headers(result[1:-1])
503 self.verify_get_called() 505 self.verify_get_called()
504 self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n') 506 self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
505 507
506 def test_with_continue_1_1(self): 508 def test_with_continue_1_1(self):
507 result = self.send_typical_request(b'GET / HTTP/1.1\r\nExpect: 100-conti nue\r\n\r\n') 509 result = self.send_typical_request(b'GET / HTTP/1.1\r\nExpect: 100-conti nue\r\n\r\n')
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 BaseHTTPServerTestCase, 605 BaseHTTPServerTestCase,
604 SimpleHTTPServerTestCase, 606 SimpleHTTPServerTestCase,
605 CGIHTTPServerTestCase, 607 CGIHTTPServerTestCase,
606 SimpleHTTPRequestHandlerTestCase, 608 SimpleHTTPRequestHandlerTestCase,
607 ) 609 )
608 finally: 610 finally:
609 os.chdir(cwd) 611 os.chdir(cwd)
610 612
611 if __name__ == '__main__': 613 if __name__ == '__main__':
612 test_main() 614 test_main()
OLDNEW
« no previous file with comments | « Lib/http/server.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7