Handle disconnects on flush.

This commit is contained in:
Aldo Cortesi 2012-07-30 11:58:29 +12:00
parent b1ac4245c8
commit 5b08703fa8
4 changed files with 20 additions and 20 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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">

View File

@ -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):