aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-07-30 11:58:29 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-07-30 12:02:42 +1200
commit5b08703fa8338407af063652658e7f570a2ec0f8 (patch)
tree3d619b149176c697b2ccf08cf9b3e952542c78c7 /libpathod
parentb1ac4245c81c07fb6b0e014a3cc8046f637d8aff (diff)
downloadmitmproxy-5b08703fa8338407af063652658e7f570a2ec0f8.tar.gz
mitmproxy-5b08703fa8338407af063652658e7f570a2ec0f8.tar.bz2
mitmproxy-5b08703fa8338407af063652658e7f570a2ec0f8.zip
Handle disconnects on flush.
Diffstat (limited to 'libpathod')
-rw-r--r--libpathod/pathoc.py2
-rw-r--r--libpathod/pathod.py26
-rw-r--r--libpathod/templates/docs_pathod.html10
-rw-r--r--libpathod/test.py2
4 files changed, 20 insertions, 20 deletions
diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py
index b78d986f..1bc340cd 100644
--- a/libpathod/pathoc.py
+++ b/libpathod/pathoc.py
@@ -65,6 +65,8 @@ class Pathoc(tcp.TCPClient):
return
except tcp.NetLibTimeout:
print >> fp, "<<", "Timeout"
+ except tcp.NetLibDisconnect:
+ print >> fp, "<<", "Disconnect"
else:
if respdump:
print_full(fp, *resp)
diff --git a/libpathod/pathod.py b/libpathod/pathod.py
index 0ae32c47..7cb7d604 100644
--- a/libpathod/pathod.py
+++ b/libpathod/pathod.py
@@ -136,17 +136,7 @@ class PathodHandler(tcp.BaseHandler):
return
while not self.finished:
- try:
- if not self.handle_request():
- return
- except tcp.NetLibDisconnect: # pragma: no cover
- self.info("Disconnect")
- self.server.add_log(
- dict(
- type = "error",
- msg = "Disconnect"
- )
- )
+ if not self.handle_request():
return
@@ -211,8 +201,18 @@ class Pathod(tcp.TCPServer):
def handle_connection(self, request, client_address):
h = PathodHandler(request, client_address, self)
- h.handle()
- h.finish()
+ try:
+ h.handle()
+ h.finish()
+ except tcp.NetLibDisconnect: # pragma: no cover
+ h.info("Disconnect")
+ self.add_log(
+ dict(
+ type = "error",
+ msg = "Disconnect"
+ )
+ )
+ return
def add_log(self, d):
if not self.noapi:
diff --git a/libpathod/templates/docs_pathod.html b/libpathod/templates/docs_pathod.html
index b5a03023..a581d18d 100644
--- a/libpathod/templates/docs_pathod.html
+++ b/libpathod/templates/docs_pathod.html
@@ -8,12 +8,10 @@
</h1>
</div>
-<p>Pathod is a pathological HTTP daemon, designed to let you craft arbitrarily
-malevolent HTTP responses. It lets you thoroughly exercise the failure modes of
-HTTP clients by creatively violating the standards. HTTP responses are
-specified using a <a href="/docs/language">small, terse language</a>, which
-pathod shares with its evil twin pathoc. </p>
-
+<p>Pathod is a pathological HTTP daemon designed to let you craft almost any
+conceivable HTTP response, including ones that creatively violate the
+standards. HTTP responses are specified using a <a href="/docs/language">small,
+terse language</a>, which pathod shares with its evil twin pathoc. </p>
<section id="api">
<div class="page-header">
diff --git a/libpathod/test.py b/libpathod/test.py
index 5bcebcb6..d5089d2c 100644
--- a/libpathod/test.py
+++ b/libpathod/test.py
@@ -44,7 +44,7 @@ class Daemon:
class PaThread(threading.Thread):
def __init__(self, q, ssl, daemonargs):
threading.Thread.__init__(self)
- self.q, self.ssl = q, ssl
+ self.q, self.ssl = q, ssl
self.daemonargs = daemonargs
def run(self):