mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
FlowMaster bugfixes and unit tests.
This commit is contained in:
parent
27f0765cdd
commit
66349c9783
@ -1334,7 +1334,7 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
self.process_flow(f, r)
|
self.process_flow(f, r)
|
||||||
|
|
||||||
def handle_response(self, r):
|
def handle_response(self, r):
|
||||||
f = flow.FlowMaster.handle_request(self, r)
|
f = flow.FlowMaster.handle_response(self, r)
|
||||||
if f:
|
if f:
|
||||||
if f.match(self.stickycookie):
|
if f.match(self.stickycookie):
|
||||||
hid = (f.request.host, f.request.port)
|
hid = (f.request.host, f.request.port)
|
||||||
|
@ -315,12 +315,7 @@ class FlowMaster(controller.Master):
|
|||||||
f = self.state.add_response(r)
|
f = self.state.add_response(r)
|
||||||
if not f:
|
if not f:
|
||||||
r.ack()
|
r.ack()
|
||||||
else:
|
return f
|
||||||
if f.match(self.stickycookie):
|
|
||||||
hid = (f.request.host, f.request.port)
|
|
||||||
if f.response.headers.has_key("set-cookie"):
|
|
||||||
self.stickyhosts[hid] = f.response.headers["set-cookie"]
|
|
||||||
self.process_flow(f, r)
|
|
||||||
|
|
||||||
|
|
||||||
class FlowWriter:
|
class FlowWriter:
|
||||||
|
@ -433,7 +433,7 @@ class ServerConnection:
|
|||||||
if code >= 100 and code <= 199:
|
if code >= 100 and code <= 199:
|
||||||
return self.read_response()
|
return self.read_response()
|
||||||
if self.request.method == "HEAD" or code == 204 or code == 304:
|
if self.request.method == "HEAD" or code == 204 or code == 304:
|
||||||
content = None
|
content = ""
|
||||||
else:
|
else:
|
||||||
content = read_http_body(self.rfile, self, headers, True)
|
content = read_http_body(self.rfile, self, headers, True)
|
||||||
return Response(self.request, code, msg, headers, content)
|
return Response(self.request, code, msg, headers, content)
|
||||||
|
@ -261,10 +261,28 @@ class uSerialize(libpry.AutoTree):
|
|||||||
assert l[0] == f
|
assert l[0] == f
|
||||||
|
|
||||||
|
|
||||||
|
class uFlowMaster(libpry.AutoTree):
|
||||||
|
def test_one(self):
|
||||||
|
s = flow.State()
|
||||||
|
f = flow.FlowMaster(None, s)
|
||||||
|
|
||||||
|
req = utils.treq()
|
||||||
|
f.handle_clientconnection(req.client_conn)
|
||||||
|
assert len(s.flow_list) == 1
|
||||||
|
f.handle_request(req)
|
||||||
|
assert len(s.flow_list) == 1
|
||||||
|
f.handle_request(req)
|
||||||
|
resp = utils.tresp()
|
||||||
|
resp.request = req
|
||||||
|
f.handle_response(resp)
|
||||||
|
assert len(s.flow_list) == 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tests = [
|
tests = [
|
||||||
uFlow(),
|
uFlow(),
|
||||||
uState(),
|
uState(),
|
||||||
uSerialize()
|
uSerialize(),
|
||||||
|
uFlowMaster()
|
||||||
|
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user