mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 02:10:59 +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
|
@property
|
||||||
def killable(self):
|
def killable(self):
|
||||||
"""*Read-only:* `True` if this flow can be killed, `False` otherwise."""
|
"""*Read-only:* `True` if this flow can be killed, `False` otherwise."""
|
||||||
return (
|
return not (self.error and self.error.msg == Error.KILLED_MESSAGE)
|
||||||
self.reply and
|
|
||||||
self.reply.state in {"start", "taken"} and
|
|
||||||
not (self.error and self.error.msg == Error.KILLED_MESSAGE)
|
|
||||||
)
|
|
||||||
|
|
||||||
def kill(self):
|
def kill(self):
|
||||||
"""
|
"""
|
||||||
|
@ -7,7 +7,6 @@ import pytest
|
|||||||
|
|
||||||
from mitmproxy import flow
|
from mitmproxy import flow
|
||||||
from mitmproxy import flowfilter
|
from mitmproxy import flowfilter
|
||||||
from mitmproxy.exceptions import ControlException
|
|
||||||
from mitmproxy.http import Headers, Request, Response, HTTPFlow
|
from mitmproxy.http import Headers, Request, Response, HTTPFlow
|
||||||
from mitmproxy.net.http.cookies import CookieAttrs
|
from mitmproxy.net.http.cookies import CookieAttrs
|
||||||
from mitmproxy.test.tflow import tflow
|
from mitmproxy.test.tflow import tflow
|
||||||
@ -704,10 +703,11 @@ class TestHTTPFlow:
|
|||||||
|
|
||||||
def test_kill(self):
|
def test_kill(self):
|
||||||
f = tflow()
|
f = tflow()
|
||||||
with pytest.raises(ControlException):
|
f.intercept()
|
||||||
f.intercept()
|
f.resume()
|
||||||
f.resume()
|
assert f.killable
|
||||||
f.kill()
|
f.kill()
|
||||||
|
assert not f.killable
|
||||||
|
|
||||||
f = tflow()
|
f = tflow()
|
||||||
f.intercept()
|
f.intercept()
|
||||||
|
Loading…
Reference in New Issue
Block a user