diff options
author | Kali Kaneko <kali@leap.se> | 2013-12-18 12:37:44 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2013-12-18 16:23:54 -0400 |
commit | 7b72e60911009e282520c5d8b6c6edd75ab48fd2 (patch) | |
tree | 9c24e07b955061e226f6cd7d6e9c83f89bc975d9 /server/src/leap/soledad | |
parent | bbf09fcabd311aa91085cedcbd2e9fbbeebc2526 (diff) |
remove conditional gzip, fix import
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 |