mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-21 22:58:24 +00:00
Flow.kill: don't depend on reply status.
In principle, a flow is killable as long as the connection handler is still checking the error status of the flow. This is patch 2/4 of the reply-ectomy.
This commit is contained in:
parent
4448550746
commit
fd43ca19c4
@ -193,11 +193,7 @@ class Flow(stateobject.StateObject):
|
||||
@property
|
||||
def killable(self):
|
||||
"""*Read-only:* `True` if this flow can be killed, `False` otherwise."""
|
||||
return (
|
||||
self.reply and
|
||||
self.reply.state in {"start", "taken"} and
|
||||
not (self.error and self.error.msg == Error.KILLED_MESSAGE)
|
||||
)
|
||||
return not (self.error and self.error.msg == Error.KILLED_MESSAGE)
|
||||
|
||||
def kill(self):
|
||||
"""
|
||||
|
@ -7,7 +7,6 @@ import pytest
|
||||
|
||||
from mitmproxy import flow
|
||||
from mitmproxy import flowfilter
|
||||
from mitmproxy.exceptions import ControlException
|
||||
from mitmproxy.http import Headers, Request, Response, HTTPFlow
|
||||
from mitmproxy.net.http.cookies import CookieAttrs
|
||||
from mitmproxy.test.tflow import tflow
|
||||
@ -704,10 +703,11 @@ class TestHTTPFlow:
|
||||
|
||||
def test_kill(self):
|
||||
f = tflow()
|
||||
with pytest.raises(ControlException):
|
||||
f.intercept()
|
||||
f.resume()
|
||||
f.kill()
|
||||
f.intercept()
|
||||
f.resume()
|
||||
assert f.killable
|
||||
f.kill()
|
||||
assert not f.killable
|
||||
|
||||
f = tflow()
|
||||
f.intercept()
|
||||
|
Loading…
Reference in New Issue
Block a user