diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-06-05 13:04:13 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-06-05 13:04:13 +1200 |
commit | 48da24ae7e7be7af94162d35a463f174e22504f6 (patch) | |
tree | 1559a5847123d98a68cfd752689c0bf5c5669577 /pathod/pathod.py | |
parent | c0c45c051a6eadf34d38f1b0d3d96c6a9196f733 (diff) | |
download | mitmproxy-48da24ae7e7be7af94162d35a463f174e22504f6.tar.gz mitmproxy-48da24ae7e7be7af94162d35a463f174e22504f6.tar.bz2 mitmproxy-48da24ae7e7be7af94162d35a463f174e22504f6.zip |
First-order removal of pathod API and app
Diffstat (limited to 'pathod/pathod.py')
-rw-r--r-- | pathod/pathod.py | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/pathod/pathod.py b/pathod/pathod.py index 0449c0c1..add33944 100644 --- a/pathod/pathod.py +++ b/pathod/pathod.py @@ -10,7 +10,7 @@ from netlib import tcp, certutils, websockets from netlib.exceptions import HttpException, HttpReadDisconnect, TcpTimeout, TcpDisconnect, \ TlsException -from . import version, app, language, utils, log, protocols +from . import version, language, utils, log, protocols DEFAULT_CERT_DOMAIN = "pathod.net" @@ -136,7 +136,6 @@ class PathodHandler(tcp.BaseHandler): path = req.path http_version = req.http_version headers = req.headers - body = req.content clientcert = None if self.clientcert: @@ -203,24 +202,27 @@ class PathodHandler(tcp.BaseHandler): self.server.craftanchor )]) - if anchor_gen: - spec = anchor_gen.next() + if not anchor_gen: + anchor_gen = iter([self.make_http_error_response( + "Not found", + "No valid craft request found" + )]) - if self.use_http2 and isinstance(spec, language.http2.Response): - spec.stream_id = req.stream_id + spec = anchor_gen.next() - lg("crafting spec: %s" % spec) - nexthandler, retlog["response"] = self.http_serve_crafted( - spec, - lg - ) - if nexthandler and websocket_key: - self.protocol = protocols.websockets.WebsocketsProtocol(self) - return self.protocol.handle_websocket, retlog - else: - return nexthandler, retlog + if self.use_http2 and isinstance(spec, language.http2.Response): + spec.stream_id = req.stream_id + + lg("crafting spec: %s" % spec) + nexthandler, retlog["response"] = self.http_serve_crafted( + spec, + lg + ) + if nexthandler and websocket_key: + self.protocol = protocols.websockets.WebsocketsProtocol(self) + return self.protocol.handle_websocket, retlog else: - return self.protocol.handle_http_app(method, path, headers, body, lg) + return nexthandler, retlog def make_http_error_response(self, reason, body=None): resp = self.protocol.make_error_response(reason, body) @@ -343,8 +345,6 @@ class Pathod(tcp.TCPServer): self.explain = explain self.logfp = logfp - self.app = app.make_app(noapi, webdebug) - self.app.config["pathod"] = self self.log = [] self.logid = 0 self.anchors = anchors |