diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-05-01 09:41:07 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-05-01 09:41:07 +1200 |
commit | 3a3ea9d927969750bc1b6fff6994048aa1b928d2 (patch) | |
tree | e096504dbf10e6e044a40eb405c5df5ef2e2755f /libpathod/pathoc.py | |
parent | b8f40860f57028a165ee392e84c7731305947784 (diff) | |
download | mitmproxy-3a3ea9d927969750bc1b6fff6994048aa1b928d2.tar.gz mitmproxy-3a3ea9d927969750bc1b6fff6994048aa1b928d2.tar.bz2 mitmproxy-3a3ea9d927969750bc1b6fff6994048aa1b928d2.zip |
pathoc: cope better with disconnect conditions
Diffstat (limited to 'libpathod/pathoc.py')
-rw-r--r-- | libpathod/pathoc.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py index 50f73848..6c01a68f 100644 --- a/libpathod/pathoc.py +++ b/libpathod/pathoc.py @@ -40,18 +40,18 @@ class Log: rlog = self.rfile.get_log() if self.rfile else None if self.suppressed or not self.fp: 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: self("Bytes written:") self.dump(wlog, self.hex) if rlog: self("Bytes read:") 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") self.fp.flush() @@ -284,7 +284,8 @@ class Pathoc(tcp.TCPClient): ) def stop(self): - self.ws_framereader.terminate.put(None) + if self.ws_framereader: + self.ws_framereader.terminate.put(None) def wait(self): if self.ws_framereader: @@ -466,11 +467,10 @@ def main(args): # pragma: nocover for spec in playlist: try: ret = p.request(spec) - sys.stdout.flush() if ret and args.oneshot: return except (http.HttpError, tcp.NetLibError), v: - pass + break p.wait() except KeyboardInterrupt: pass |