summaryrefslogtreecommitdiffstats
path: root/pyload/webui/middlewares.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/webui/middlewares.py')
-rw-r--r--pyload/webui/middlewares.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/pyload/webui/middlewares.py b/pyload/webui/middlewares.py
index 19328f9ef..26537f900 100644
--- a/pyload/webui/middlewares.py
+++ b/pyload/webui/middlewares.py
@@ -8,19 +8,23 @@ except ImportError:
from StringIO import StringIO
class StripPathMiddleware(object):
+
def __init__(self, app):
self.app = app
+
def __call__(self, e, h):
e['PATH_INFO'] = e['PATH_INFO'].rstrip('/')
return self.app(e, h)
class PrefixMiddleware(object):
+
def __init__(self, app, prefix="/pyload"):
self.app = app
self.prefix = prefix
+
def __call__(self, e, h):
path = e["PATH_INFO"]
if path.startswith(self.prefix):
@@ -42,6 +46,7 @@ class GZipMiddleWare(object):
self.application = application
self.compress_level = int(compress_level)
+
def __call__(self, environ, start_response):
if 'gzip' not in environ.get('HTTP_ACCEPT_ENCODING', ''):
# nothing for us to do, so this middleware will
@@ -80,6 +85,7 @@ class GzipResponse(object):
self.content_length = None
self.headers = ()
+
def gzip_start_response(self, status, headers, exc_info=None):
self.headers = headers
ct = header_value(headers,'content-type')
@@ -102,6 +108,7 @@ class GzipResponse(object):
self.status = status
return self.buffer.write
+
def write(self):
out = self.buffer
out.seek(0)
@@ -109,6 +116,7 @@ class GzipResponse(object):
out.close()
return [s]
+
def finish_response(self, app_iter):
if self.compressible:
output = gzip.GzipFile(mode='wb', compresslevel=self.compress_level,