diff options
Diffstat (limited to 'server/src/leap/soledad')
-rw-r--r-- | server/src/leap/soledad/server/__init__.py | 2 | ||||
-rw-r--r-- | server/src/leap/soledad/server/gzip_middleware.py (renamed from server/src/leap/soledad/server/gzip.py) | 11 |
2 files changed, 6 insertions, 7 deletions
diff --git a/server/src/leap/soledad/server/__init__.py b/server/src/leap/soledad/server/__init__.py index de5daf62..a4b25fe2 100644 --- a/server/src/leap/soledad/server/__init__.py +++ b/server/src/leap/soledad/server/__init__.py @@ -110,7 +110,7 @@ if version.base() == "12.0.0": sys.modules['OpenSSL.tsafe'] = old_tsafe from leap.soledad.server.auth import SoledadTokenAuthMiddleware -from leap.soledad.server.gzip import GzipMiddleware +from leap.soledad.server.gzip_middleware import GzipMiddleware from leap.soledad.common import ( SHARED_DB_NAME, diff --git a/server/src/leap/soledad/server/gzip.py b/server/src/leap/soledad/server/gzip_middleware.py index 92906513..5a424894 100644 --- a/server/src/leap/soledad/server/gzip.py +++ b/server/src/leap/soledad/server/gzip_middleware.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# gzip.py +# gzip_middleware.py # Copyright (C) 2013 LEAP # # This program is free software: you can redistribute it and/or modify @@ -17,8 +17,8 @@ """ Gzip middleware for WSGI apps. """ -import gzip import StringIO +from gzip import GzipFile class GzipMiddleware(object): @@ -30,13 +30,12 @@ class GzipMiddleware(object): self.compresslevel = compresslevel def __call__(self, environ, start_response): + print "environ: ", environ if 'gzip' not in environ.get('HTTP_ACCEPT_ENCODING', ''): return self.app(environ, start_response) - if (environ['PATH_INFO'][-3:] != '.js' and environ[ - 'PATH_INFO'][-4:] != '.css'): - return self.app(environ, start_response) + buffer = StringIO.StringIO() - output = gzip.GzipFile( + output = GzipFile( mode='wb', compresslevel=self.compresslevel, fileobj=buffer |