diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-07-23 19:55:33 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-07-23 19:55:33 +1200 |
commit | 622a2b560753f2e4aa96bfb4e97bfcac4d0bedbd (patch) | |
tree | 8295e8d3b487a605c5051a9abaf16e1840871eae /libpathod/pathod.py | |
parent | eba485f5ebef6975c60eb29e69e03aa7598d59b8 (diff) | |
download | mitmproxy-622a2b560753f2e4aa96bfb4e97bfcac4d0bedbd.tar.gz mitmproxy-622a2b560753f2e4aa96bfb4e97bfcac4d0bedbd.tar.bz2 mitmproxy-622a2b560753f2e4aa96bfb4e97bfcac4d0bedbd.zip |
Add a --noweb option to turn web iface off, refactor unit tests.
Diffstat (limited to 'libpathod/pathod.py')
-rw-r--r-- | libpathod/pathod.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py index 12719d13..c95a8ed0 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -92,7 +92,13 @@ class PathodHandler(tcp.BaseHandler): ) ) if response_log["disconnect"]: - return + return False + return True + + if self.server.noweb: + crafted = rparse.PathodErrorResponse("Access Denied") + crafted.serve(self.wfile, self.server.check_size) + return False else: cc = wsgi.ClientConn(self.client_address) req = wsgi.Request(cc, "http", method, path, headers, content) @@ -105,7 +111,7 @@ class PathodHandler(tcp.BaseHandler): ) app.serve(req, self.wfile) self.debug("%s %s"%(method, path)) - return True + return True def handle(self): if self.server.ssloptions: @@ -142,7 +148,10 @@ class PathodHandler(tcp.BaseHandler): class Pathod(tcp.TCPServer): LOGBUF = 500 - def __init__(self, addr, ssloptions=None, prefix="/p/", staticdir=None, anchors=None, sizelimit=None): + def __init__( self, + addr, ssloptions=None, prefix="/p/", staticdir=None, anchors=None, + sizelimit=None, noweb=False + ): """ addr: (address, port) tuple. If port is 0, a free port will be automatically chosen. @@ -158,6 +167,7 @@ class Pathod(tcp.TCPServer): self.prefix = prefix self.sizelimit = sizelimit self.app = app.app + self.noweb = noweb self.app.config["pathod"] = self self.log = [] self.logid = 0 |