mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-12-03 12:23:46 +00:00
pathoc: cope better with disconnect conditions
This commit is contained in:
parent
b8f40860f5
commit
3a3ea9d927
@ -40,18 +40,18 @@ class Log:
|
|||||||
rlog = self.rfile.get_log() if self.rfile else None
|
rlog = self.rfile.get_log() if self.rfile else None
|
||||||
if self.suppressed or not self.fp:
|
if self.suppressed or not self.fp:
|
||||||
return
|
return
|
||||||
if exc_type == tcp.NetLibTimeout:
|
|
||||||
self("Timeout")
|
|
||||||
elif exc_type == tcp.NetLibDisconnect:
|
|
||||||
self("Disconnect")
|
|
||||||
elif exc_type == http.HttpError:
|
|
||||||
self("HTTP Error: %s"%exc_value.message)
|
|
||||||
if wlog:
|
if wlog:
|
||||||
self("Bytes written:")
|
self("Bytes written:")
|
||||||
self.dump(wlog, self.hex)
|
self.dump(wlog, self.hex)
|
||||||
if rlog:
|
if rlog:
|
||||||
self("Bytes read:")
|
self("Bytes read:")
|
||||||
self.dump(rlog, self.hex)
|
self.dump(rlog, self.hex)
|
||||||
|
if exc_type == tcp.NetLibTimeout:
|
||||||
|
self("Timeout")
|
||||||
|
elif exc_type in (tcp.NetLibDisconnect, http.HttpErrorConnClosed):
|
||||||
|
self("Disconnected")
|
||||||
|
elif exc_type == http.HttpError:
|
||||||
|
self("HTTP Error: %s"%exc_value.message)
|
||||||
self.fp.write("\n".join(self.lines))
|
self.fp.write("\n".join(self.lines))
|
||||||
self.fp.write("\n")
|
self.fp.write("\n")
|
||||||
self.fp.flush()
|
self.fp.flush()
|
||||||
@ -284,7 +284,8 @@ class Pathoc(tcp.TCPClient):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.ws_framereader.terminate.put(None)
|
if self.ws_framereader:
|
||||||
|
self.ws_framereader.terminate.put(None)
|
||||||
|
|
||||||
def wait(self):
|
def wait(self):
|
||||||
if self.ws_framereader:
|
if self.ws_framereader:
|
||||||
@ -466,11 +467,10 @@ def main(args): # pragma: nocover
|
|||||||
for spec in playlist:
|
for spec in playlist:
|
||||||
try:
|
try:
|
||||||
ret = p.request(spec)
|
ret = p.request(spec)
|
||||||
sys.stdout.flush()
|
|
||||||
if ret and args.oneshot:
|
if ret and args.oneshot:
|
||||||
return
|
return
|
||||||
except (http.HttpError, tcp.NetLibError), v:
|
except (http.HttpError, tcp.NetLibError), v:
|
||||||
pass
|
break
|
||||||
p.wait()
|
p.wait()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user