aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/pathod.py
diff options
context:
space:
mode:
Diffstat (limited to 'libpathod/pathod.py')
-rw-r--r--libpathod/pathod.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py
index 8a29b9cb..e0a0764f 100644
--- a/libpathod/pathod.py
+++ b/libpathod/pathod.py
@@ -18,6 +18,10 @@ class PathodHandler(tcp.BaseHandler):
return None
method, path, httpversion = protocol.parse_init_http(line)
+ headers = odict.ODictCaseless(protocol.read_headers(self.rfile))
+ content = protocol.read_http_body_request(
+ self.rfile, self.wfile, headers, httpversion, None
+ )
if path.startswith(self.server.prefix):
spec = urllib.unquote(path)[len(self.server.prefix):]
try:
@@ -27,24 +31,20 @@ class PathodHandler(tcp.BaseHandler):
800,
"Error parsing response spec: %s\n"%v.msg + v.marked()
)
- presp.serve(self.wfile)
- self.finish()
- return
-
- headers = odict.ODictCaseless(protocol.read_headers(self.rfile))
- content = protocol.read_http_body_request(
- self.rfile, self.wfile, headers, httpversion, None
- )
- cc = wsgi.ClientConn(self.client_address)
- req = wsgi.Request(cc, "http", method, path, headers, content)
- sn = self.connection.getsockname()
- app = wsgi.WSGIAdaptor(
- self.server.app,
- sn[0],
- self.server.port,
- version.NAMEVERSION
- )
- app.serve(req, self.wfile)
+ ret = presp.serve(self.wfile)
+ if ret["disconnect"]:
+ self.close()
+ else:
+ cc = wsgi.ClientConn(self.client_address)
+ req = wsgi.Request(cc, "http", method, path, headers, content)
+ sn = self.connection.getsockname()
+ app = wsgi.WSGIAdaptor(
+ self.server.app,
+ sn[0],
+ self.server.port,
+ version.NAMEVERSION
+ )
+ app.serve(req, self.wfile)
class Pathod(tcp.TCPServer):