diff options
Diffstat (limited to 'libpathod')
-rw-r--r-- | libpathod/pathod.py | 16 | ||||
-rw-r--r-- | libpathod/test.py | 10 |
2 files changed, 19 insertions, 7 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 diff --git a/libpathod/test.py b/libpathod/test.py index ff5dac30..e8ca536a 100644 --- a/libpathod/test.py +++ b/libpathod/test.py @@ -5,9 +5,9 @@ import pathod, utils IFACE = "127.0.0.1" class Daemon: - def __init__(self, staticdir=None, anchors=(), ssl=None, sizelimit=None): + def __init__(self, staticdir=None, anchors=(), ssl=None, sizelimit=None, noweb=False): self.q = Queue.Queue() - self.thread = PaThread(self.q, staticdir, anchors, ssl, sizelimit) + self.thread = PaThread(self.q, staticdir, anchors, ssl, sizelimit, noweb) self.thread.start() self.port = self.q.get(True, 5) self.urlbase = "%s://%s:%s"%("https" if ssl else "http", IFACE, self.port) @@ -42,9 +42,10 @@ class Daemon: class PaThread(threading.Thread): - def __init__(self, q, staticdir, anchors, ssl, sizelimit): + def __init__(self, q, staticdir, anchors, ssl, sizelimit, noweb): threading.Thread.__init__(self) self.q, self.staticdir, self.anchors, self.ssl, self.sizelimit = q, staticdir, anchors, ssl, sizelimit + self.noweb = noweb def run(self): if self.ssl is True: @@ -59,7 +60,8 @@ class PaThread(threading.Thread): ssloptions = ssloptions, anchors = self.anchors, staticdir = self.staticdir, - sizelimit = self.sizelimit + sizelimit = self.sizelimit, + noweb = self.noweb ) self.q.put(self.server.port) self.server.serve_forever() |