mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
introduce ConnectRequest class
This commit is contained in:
parent
4617ab8a3a
commit
37a0cb858c
@ -380,7 +380,7 @@ class HTTP1Protocol(object):
|
||||
"Bad HTTP request line: %s" % repr(request_line)
|
||||
)
|
||||
host, port, _ = r
|
||||
path = None
|
||||
return http.ConnectRequest(host, port)
|
||||
else:
|
||||
form_in = "absolute"
|
||||
r = self.parse_init_proxy(request_line)
|
||||
|
@ -19,7 +19,7 @@ class Request(object):
|
||||
path,
|
||||
httpversion,
|
||||
headers,
|
||||
content,
|
||||
body,
|
||||
):
|
||||
self.form_in = form_in
|
||||
self.method = method
|
||||
@ -29,7 +29,7 @@ class Request(object):
|
||||
self.path = path
|
||||
self.httpversion = httpversion
|
||||
self.headers = headers
|
||||
self.content = content
|
||||
self.body = body
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.__dict__ == other.__dict__
|
||||
@ -38,6 +38,21 @@ class Request(object):
|
||||
return "Request(%s - %s, %s)" % (self.method, self.host, self.path)
|
||||
|
||||
|
||||
class ConnectRequest(Request):
|
||||
def __init__(self, host, port):
|
||||
super(ConnectRequest, self).__init__(
|
||||
form_in="authority",
|
||||
method="CONNECT",
|
||||
scheme="",
|
||||
host=host,
|
||||
port=port,
|
||||
path="",
|
||||
httpversion="",
|
||||
headers="",
|
||||
body="",
|
||||
)
|
||||
|
||||
|
||||
class Response(object):
|
||||
|
||||
def __init__(
|
||||
@ -46,14 +61,14 @@ class Response(object):
|
||||
status_code,
|
||||
msg,
|
||||
headers,
|
||||
content,
|
||||
body,
|
||||
sslinfo=None,
|
||||
):
|
||||
self.httpversion = httpversion
|
||||
self.status_code = status_code
|
||||
self.msg = msg
|
||||
self.headers = headers
|
||||
self.content = content
|
||||
self.body = body
|
||||
self.sslinfo = sslinfo
|
||||
|
||||
def __eq__(self, other):
|
||||
@ -63,7 +78,6 @@ class Response(object):
|
||||
return "Response(%s - %s)" % (self.status_code, self.msg)
|
||||
|
||||
|
||||
|
||||
def is_valid_port(port):
|
||||
if not 0 <= port <= 65535:
|
||||
return False
|
||||
|
@ -20,6 +20,8 @@ class ODict(object):
|
||||
"""
|
||||
|
||||
def __init__(self, lst=None):
|
||||
if isinstance(lst, ODict):
|
||||
lst = lst.items()
|
||||
self.lst = lst or []
|
||||
|
||||
def _kconv(self, s):
|
||||
|
Loading…
Reference in New Issue
Block a user