Commit 0b6c8223 authored by Luca Wehrstedt's avatar Luca Wehrstedt Committed by Denis Bilenko

Fix #79: Properly handle HTTP versions

Close #296.
parent 4ff63bf7
......@@ -29,8 +29,8 @@ _INTERNAL_ERROR_BODY = 'Internal Server Error'
_INTERNAL_ERROR_HEADERS = [('Content-Type', 'text/plain'),
('Connection', 'close'),
('Content-Length', str(len(_INTERNAL_ERROR_BODY)))]
_REQUEST_TOO_LONG_RESPONSE = "HTTP/1.0 414 Request URI Too Long\r\nConnection: close\r\nContent-length: 0\r\n\r\n"
_BAD_REQUEST_RESPONSE = "HTTP/1.0 400 Bad Request\r\nConnection: close\r\nContent-length: 0\r\n\r\n"
_REQUEST_TOO_LONG_RESPONSE = "HTTP/1.1 414 Request URI Too Long\r\nConnection: close\r\nContent-length: 0\r\n\r\n"
_BAD_REQUEST_RESPONSE = "HTTP/1.1 400 Bad Request\r\nConnection: close\r\nContent-length: 0\r\n\r\n"
_CONTINUE_RESPONSE = "HTTP/1.1 100 Continue\r\n\r\n"
......@@ -386,7 +386,7 @@ class WSGIHandler(object):
self.headers_sent = True
self.finalize_headers()
towrite.extend('%s %s\r\n' % (self.request_version, self.status))
towrite.extend('HTTP/1.1 %s\r\n' % self.status)
for header in self.response_headers:
towrite.extend('%s: %s\r\n' % header)
......@@ -407,7 +407,7 @@ class WSGIHandler(object):
self.headers_sent = True
self.finalize_headers()
towrite.append('%s %s\r\n' % (self.request_version, self.status))
towrite.append('HTTP/1.1 %s\r\n' % self.status)
for header in self.response_headers:
towrite.append('%s: %s\r\n' % header)
......@@ -562,7 +562,7 @@ class WSGIHandler(object):
length = self.headers.getheader('content-length')
if length:
env['CONTENT_LENGTH'] = length
env['SERVER_PROTOCOL'] = 'HTTP/1.0'
env['SERVER_PROTOCOL'] = self.request_version
client_address = self.client_address
if isinstance(client_address, tuple):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment