mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #16088: BaseHTTPRequestHandler's send_error method includes a
Content-Length header. Patch by Antoine Pitrou.
This commit is contained in:
parent
ec7c16d2b4
commit
52d2720499
4 changed files with 21 additions and 1 deletions
|
@ -92,6 +92,9 @@ class BaseHTTPServerTestCase(BaseTestCase):
|
|||
def do_KEYERROR(self):
|
||||
self.send_error(999)
|
||||
|
||||
def do_NOTFOUND(self):
|
||||
self.send_error(404)
|
||||
|
||||
def do_CUSTOM(self):
|
||||
self.send_response(999)
|
||||
self.send_header('Content-Type', 'text/html')
|
||||
|
@ -211,6 +214,15 @@ class BaseHTTPServerTestCase(BaseTestCase):
|
|||
self.assertEqual(res.getheader('X-Special'), 'Dängerous Mind')
|
||||
self.assertEqual(res.read(), 'Ärger mit Unicode'.encode('utf-8'))
|
||||
|
||||
def test_error_content_length(self):
|
||||
# Issue #16088: standard error responses should have a content-length
|
||||
self.con.request('NOTFOUND', '/')
|
||||
res = self.con.getresponse()
|
||||
self.assertEqual(res.status, 404)
|
||||
data = res.read()
|
||||
import pdb; pdb.set_trace()
|
||||
self.assertEqual(int(res.getheader('Content-Length')), len(data))
|
||||
|
||||
|
||||
class SimpleHTTPServerTestCase(BaseTestCase):
|
||||
class request_handler(NoLogRequestHandler, SimpleHTTPRequestHandler):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue