introduce EmptyRequest class

This commit is contained in:
Thomas Kriechbaumer 2015-07-19 20:46:26 +02:00
parent d62dbee0f6
commit 83f013fca1
2 changed files with 19 additions and 2 deletions

View File

@ -333,7 +333,7 @@ class HTTP1Protocol(object):
return -1
def read_request(self, include_body=True, body_size_limit=None):
def read_request(self, include_body=True, body_size_limit=None, allow_empty=False):
"""
Parse an HTTP request from a file stream
@ -354,7 +354,10 @@ class HTTP1Protocol(object):
request_line = self.get_request_line()
if not request_line:
raise tcp.NetLibDisconnect()
if allow_empty:
return http.EmptyRequest()
else:
raise tcp.NetLibDisconnect()
request_line_parts = self.parse_init(request_line)
if not request_line_parts:

View File

@ -38,6 +38,20 @@ class Request(object):
return "Request(%s - %s, %s)" % (self.method, self.host, self.path)
class EmptyRequest(Request):
def __init__(self):
super(EmptyRequest, self).__init__(
form_in="",
method="",
scheme="",
host="",
port="",
path="",
httpversion="",
headers="",
body="",
)
class ConnectRequest(Request):
def __init__(self, host, port):
super(ConnectRequest, self).__init__(