diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-07-23 14:37:00 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-07-23 14:37:00 +1200 |
commit | c7b5faf7dbaab518bbe9942f018861f738ebb2b0 (patch) | |
tree | 3bdc5c6f10cc55e768936e1e7421b7e08074f6b4 /libpathod/pathod.py | |
parent | 204a556aa7dbfd37daeb6605318ebc4b7ae8c6b1 (diff) | |
download | mitmproxy-c7b5faf7dbaab518bbe9942f018861f738ebb2b0.tar.gz mitmproxy-c7b5faf7dbaab518bbe9942f018861f738ebb2b0.tar.bz2 mitmproxy-c7b5faf7dbaab518bbe9942f018861f738ebb2b0.zip |
Add hooks for policy checks of served data.
Diffstat (limited to 'libpathod/pathod.py')
-rw-r--r-- | libpathod/pathod.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py index 5180361b..2f9717df 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -86,7 +86,7 @@ class PathodHandler(tcp.BaseHandler): httpversion = httpversion, ) if crafted: - response_log = crafted.serve(self.wfile) + response_log = crafted.serve(self.wfile, self.check_size) if response_log["disconnect"]: return self.server.add_log( @@ -110,6 +110,9 @@ class PathodHandler(tcp.BaseHandler): self.debug("%s %s"%(method, path)) return True + def check_size(self, req, actions): + return False + def handle(self): if self.server.ssloptions: try: @@ -145,7 +148,7 @@ class PathodHandler(tcp.BaseHandler): class Pathod(tcp.TCPServer): LOGBUF = 500 - def __init__(self, addr, ssloptions=None, prefix="/p/", staticdir=None, anchors=None): + def __init__(self, addr, ssloptions=None, prefix="/p/", staticdir=None, anchors=None, sizelimit=None): """ addr: (address, port) tuple. If port is 0, a free port will be automatically chosen. @@ -153,11 +156,13 @@ class Pathod(tcp.TCPServer): prefix: string specifying the prefix at which to anchor response generation. staticdir: path to a directory of static resources, or None. anchors: A list of (regex, spec) tuples, or None. + sizelimit: Limit size of served data. """ tcp.TCPServer.__init__(self, addr) self.ssloptions = ssloptions self.staticdir = staticdir self.prefix = prefix + self.sizelimit = sizelimit self.app = app.app self.app.config["pathod"] = self self.log = [] |