diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-07-30 12:53:41 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-07-30 12:53:41 +1200 |
commit | 43314c77c8786367d4a52a55f642dd3d578a2a2b (patch) | |
tree | c45baef7242b59b24efa2d32ca737b71b465ee15 /libpathod | |
parent | 5b08703fa8338407af063652658e7f570a2ec0f8 (diff) | |
download | mitmproxy-43314c77c8786367d4a52a55f642dd3d578a2a2b.tar.gz mitmproxy-43314c77c8786367d4a52a55f642dd3d578a2a2b.tar.bz2 mitmproxy-43314c77c8786367d4a52a55f642dd3d578a2a2b.zip |
Handle invalid headers better.
Diffstat (limited to 'libpathod')
-rw-r--r-- | libpathod/pathod.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py index 7cb7d604..e4889cac 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -55,6 +55,17 @@ class PathodHandler(tcp.BaseHandler): method, path, httpversion = parts headers = http.read_headers(self.rfile) + if headers is None: + s = "Invalid headers" + self.info(s) + self.server.add_log( + dict( + type = "error", + msg = s + ) + ) + return + request_log = dict( path = path, method = method, @@ -82,7 +93,8 @@ class PathodHandler(tcp.BaseHandler): for i in self.server.anchors: if i[0].match(path): self.info("Serving anchor: %s"%path) - return self.serve_crafted(i[1], request_log) + aresp = rparse.parse_response(self.server.request_settings, i[1]) + return self.serve_crafted(aresp, request_log) if not self.server.nocraft and path.startswith(self.server.craftanchor): spec = urllib.unquote(path)[len(self.server.craftanchor):] @@ -181,7 +193,7 @@ class Pathod(tcp.TCPServer): aresp = rparse.parse_response(self.request_settings, i[1]) except rparse.ParseException, v: raise PathodError("Invalid page spec in anchor: '%s', %s"%(i[1], str(v))) - self.anchors.append((arex, aresp)) + self.anchors.append((arex, i[1])) def check_policy(self, req, actions): """ |