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

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

Issue 10980: http.server Header Unicode Bug
Patch Set: Created 8 years, 6 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 self.send_header('Connection', 'keep-alive') 88 self.send_header('Connection', 'keep-alive')
89 self.end_headers() 89 self.end_headers()
90 90
91 def do_KEYERROR(self): 91 def do_KEYERROR(self):
92 self.send_error(999) 92 self.send_error(999)
93 93
94 def do_CUSTOM(self): 94 def do_CUSTOM(self):
95 self.send_response(999) 95 self.send_response(999)
96 self.send_header('Content-Type', 'text/html') 96 self.send_header('Content-Type', 'text/html')
97 self.send_header('Connection', 'close') 97 self.send_header('Connection', 'close')
98 self.end_headers()
99
100 def do_LATINONEHEADER(self):
101 self.send_response(999)
102 self.send_header('X-Special', 'Dängerous Mind')
98 self.end_headers() 103 self.end_headers()
99 104
100 def setUp(self): 105 def setUp(self):
101 BaseTestCase.setUp(self) 106 BaseTestCase.setUp(self)
102 self.con = http.client.HTTPConnection('localhost', self.PORT) 107 self.con = http.client.HTTPConnection('localhost', self.PORT)
103 self.con.connect() 108 self.con.connect()
104 109
105 def test_command(self): 110 def test_command(self):
106 self.con.request('GET', '/') 111 self.con.request('GET', '/')
107 res = self.con.getresponse() 112 res = self.con.getresponse()
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 191
187 def test_internal_key_error(self): 192 def test_internal_key_error(self):
188 self.con.request('KEYERROR', '/') 193 self.con.request('KEYERROR', '/')
189 res = self.con.getresponse() 194 res = self.con.getresponse()
190 self.assertEqual(res.status, 999) 195 self.assertEqual(res.status, 999)
191 196
192 def test_return_custom_status(self): 197 def test_return_custom_status(self):
193 self.con.request('CUSTOM', '/') 198 self.con.request('CUSTOM', '/')
194 res = self.con.getresponse() 199 res = self.con.getresponse()
195 self.assertEqual(res.status, 999) 200 self.assertEqual(res.status, 999)
201
202 def test_latin1_header(self):
203 self.con.request('LATINONEHEADER', '/')
204 res = self.con.getresponse()
205 self.assertEqual(res.getheader('X-Special'), 'Dängerous Mind')
196 206
197 207
198 class SimpleHTTPServerTestCase(BaseTestCase): 208 class SimpleHTTPServerTestCase(BaseTestCase):
199 class request_handler(NoLogRequestHandler, SimpleHTTPRequestHandler): 209 class request_handler(NoLogRequestHandler, SimpleHTTPRequestHandler):
200 pass 210 pass
201 211
202 def setUp(self): 212 def setUp(self):
203 BaseTestCase.setUp(self) 213 BaseTestCase.setUp(self)
204 self.cwd = os.getcwd() 214 self.cwd = os.getcwd()
205 basetempdir = tempfile.gettempdir() 215 basetempdir = tempfile.gettempdir()
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 BaseHTTPServerTestCase, 620 BaseHTTPServerTestCase,
611 SimpleHTTPServerTestCase, 621 SimpleHTTPServerTestCase,
612 CGIHTTPServerTestCase, 622 CGIHTTPServerTestCase,
613 SimpleHTTPRequestHandlerTestCase, 623 SimpleHTTPRequestHandlerTestCase,
614 ) 624 )
615 finally: 625 finally:
616 os.chdir(cwd) 626 os.chdir(cwd)
617 627
618 if __name__ == '__main__': 628 if __name__ == '__main__':
619 test_main() 629 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 894c83f36cb7+