mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-30 14:58:38 +00:00
introduce EmptyRequest class
This commit is contained in:
parent
d62dbee0f6
commit
83f013fca1
@ -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:
|
||||
|
@ -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__(
|
||||
|
Loading…
Reference in New Issue
Block a user