[svn r97] Fix for reason phrase persisting across http/1.1 requests.
This commit is contained in:
@@ -415,8 +415,7 @@ class HttpProtocol(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||||||
self.socket = self.request = self.rfile = self.wfile = request
|
self.socket = self.request = self.rfile = self.wfile = request
|
||||||
self.client_address = client_address
|
self.client_address = client_address
|
||||||
self.server = server
|
self.server = server
|
||||||
self._code = 200
|
self.set_response_code(None, 200, None)
|
||||||
self._message = 'OK'
|
|
||||||
self.protocol_version = server.max_http_version
|
self.protocol_version = server.max_http_version
|
||||||
|
|
||||||
def set_response_code(self, request, code, message):
|
def set_response_code(self, request, code, message):
|
||||||
@@ -482,7 +481,7 @@ class HttpProtocol(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||||||
self.close_connection = True
|
self.close_connection = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self._code = 200
|
self.set_response_code(None, 200, None)
|
||||||
request = Request(self, self.command, self.path, self.headers)
|
request = Request(self, self.command, self.path, self.headers)
|
||||||
request.set_header('Server', self.version_string())
|
request.set_header('Server', self.version_string())
|
||||||
request.set_header('Date', self.date_time_string())
|
request.set_header('Date', self.date_time_string())
|
||||||
|
@@ -42,6 +42,10 @@ from eventlet import tests
|
|||||||
|
|
||||||
class Site(object):
|
class Site(object):
|
||||||
def handle_request(self, req):
|
def handle_request(self, req):
|
||||||
|
path = req.path_segments()
|
||||||
|
if len(path) > 0 and path[0] == "notexist":
|
||||||
|
req.response(404, body='not found')
|
||||||
|
return
|
||||||
req.write('hello world')
|
req.write('hello world')
|
||||||
|
|
||||||
def adapt(self, obj, req):
|
def adapt(self, obj, req):
|
||||||
@@ -185,7 +189,18 @@ class TestHttpd(tests.TestCase):
|
|||||||
self.assertEqual(body, 'a is a, body is a=a')
|
self.assertEqual(body, 'a is a, body is a=a')
|
||||||
sock.close()
|
sock.close()
|
||||||
|
|
||||||
|
def test_008_correctresponse(self):
|
||||||
|
sock = api.connect_tcp(
|
||||||
|
('127.0.0.1', 12346))
|
||||||
|
|
||||||
|
sock.write('GET / HTTP/1.1\r\nHost: localhost\r\n\r\n')
|
||||||
|
response_line_200,_,_ = read_http(sock)
|
||||||
|
sock.write('GET /notexist HTTP/1.1\r\nHost: localhost\r\n\r\n')
|
||||||
|
response_line_404,_,_ = read_http(sock)
|
||||||
|
sock.write('GET / HTTP/1.1\r\nHost: localhost\r\n\r\n')
|
||||||
|
response_line_test,_,_ = read_http(sock)
|
||||||
|
self.assertEqual(response_line_200,response_line_test)
|
||||||
|
sock.close()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Reference in New Issue
Block a user