aboutsummaryrefslogtreecommitdiffstats
path: root/netlib
diff options
context:
space:
mode:
Diffstat (limited to 'netlib')
-rw-r--r--netlib/http/http1/protocol.py7
-rw-r--r--netlib/http/semantics.py14
2 files changed, 19 insertions, 2 deletions
diff --git a/netlib/http/http1/protocol.py b/netlib/http/http1/protocol.py
index 257efb19..d2a77399 100644
--- a/netlib/http/http1/protocol.py
+++ b/netlib/http/http1/protocol.py
@@ -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:
diff --git a/netlib/http/semantics.py b/netlib/http/semantics.py
index 664f9def..355906dd 100644
--- a/netlib/http/semantics.py
+++ b/netlib/http/semantics.py
@@ -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__(