diff options
| author | Aldo Cortesi <aldo@nullcube.com> | 2012-10-01 12:01:02 +1300 |
|---|---|---|
| committer | Aldo Cortesi <aldo@nullcube.com> | 2012-10-01 12:01:02 +1300 |
| commit | 915bcfbd305d7b18de07f4f40dab1e49a06b132c (patch) | |
| tree | 1b2e0226e9ad9e3a5ac97d643886faa80740b113 /libpathod/pathod.py | |
| parent | 8bb81be2b07b4b93a8ec7c088bf1ff4728fcec21 (diff) | |
| download | mitmproxy-915bcfbd305d7b18de07f4f40dab1e49a06b132c.tar.gz mitmproxy-915bcfbd305d7b18de07f4f40dab1e49a06b132c.tar.bz2 mitmproxy-915bcfbd305d7b18de07f4f40dab1e49a06b132c.zip | |
Add timeout argument to Pathod, and matching -t command-line option.
Diffstat (limited to 'libpathod/pathod.py')
| -rw-r--r-- | libpathod/pathod.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py index 1c53d7d7..3cf96206 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -145,7 +145,7 @@ class PathodHandler(tcp.BaseHandler): ) self.info(s) return - + self.settimeout(self.server.timeout) while not self.finished: if not self.handle_request(): return @@ -155,7 +155,8 @@ class Pathod(tcp.TCPServer): LOGBUF = 500 def __init__( self, addr, ssloptions=None, craftanchor="/p/", staticdir=None, anchors=None, - sizelimit=None, noweb=False, nocraft=False, noapi=False, nohang=False + sizelimit=None, noweb=False, nocraft=False, noapi=False, nohang=False, + timeout=None ): """ addr: (address, port) tuple. If port is 0, a free port will be @@ -175,6 +176,7 @@ class Pathod(tcp.TCPServer): self.craftanchor = craftanchor self.sizelimit = sizelimit self.noweb, self.nocraft, self.noapi, self.nohang = noweb, nocraft, noapi, nohang + self.timeout = timeout if not noapi: app.api() self.app = app.app @@ -224,6 +226,14 @@ class Pathod(tcp.TCPServer): ) ) return + except tcp.NetLibTimeout: # pragma: no cover + h.info("Timeout") + self.add_log( + dict( + type = "timeout", + ) + ) + return def add_log(self, d): if not self.noapi: |
