mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
More timeout improvements
This commit is contained in:
parent
3ad73dfb5b
commit
97fdb9ef0c
@ -120,7 +120,8 @@ class WebsocketFrameReader(threading.Thread):
|
||||
if self.ws_read_limit == 0:
|
||||
return
|
||||
r, _, x = select.select([self.rfile], [], [], 0.05)
|
||||
if not r and time.time() - starttime > self.timeout:
|
||||
delta = time.time() - starttime
|
||||
if not r and self.timeout and delta > self.timeout:
|
||||
return
|
||||
try:
|
||||
self.terminate.get_nowait()
|
||||
@ -233,8 +234,6 @@ class Pathoc(tcp.TCPClient):
|
||||
an HTTP CONNECT request.
|
||||
"""
|
||||
tcp.TCPClient.connect(self)
|
||||
if self.timeout:
|
||||
self.settimeout(self.timeout)
|
||||
if connect_to:
|
||||
self.http_connect(connect_to)
|
||||
self.sslinfo = None
|
||||
@ -254,6 +253,8 @@ class Pathoc(tcp.TCPClient):
|
||||
)
|
||||
if showssl:
|
||||
print >> fp, str(self.sslinfo)
|
||||
if self.timeout:
|
||||
self.settimeout(self.timeout)
|
||||
|
||||
def _resp_summary(self, resp):
|
||||
return "<< %s %s: %s bytes" % (
|
||||
|
@ -213,10 +213,9 @@ class CommonTests(tutils.DaemonTests):
|
||||
|
||||
def test_websocket_frame(self):
|
||||
r, _ = self.pathoc(
|
||||
["ws:/p/", "wf:f'wf:b\"test\"'"],
|
||||
["ws:/p/", "wf:f'wf:b\"test\"':pa,1"],
|
||||
ws_read_limit=1
|
||||
)
|
||||
print >> sys.stderr, r
|
||||
assert r[1].payload == "test"
|
||||
|
||||
def test_websocket_frame_reflect_error(self):
|
||||
|
@ -85,11 +85,10 @@ class DaemonTests(object):
|
||||
("localhost", self.d.port),
|
||||
ssl=ssl,
|
||||
ws_read_limit=ws_read_limit,
|
||||
timeout = timeout,
|
||||
fp = logfp
|
||||
)
|
||||
c.connect(connect_to)
|
||||
if timeout:
|
||||
c.settimeout(timeout)
|
||||
ret = []
|
||||
for i in specs:
|
||||
resp = c.request(i)
|
||||
|
Loading…
Reference in New Issue
Block a user