-from twisted.web import resource, server, static
-from qwebirc.util.gziprequest import GZipRequest
+from twisted.web import resource, server, static, error
import qwebirc.util as util
import pprint
from adminengine import AdminEngineAction
+try:
+ from twisted.web.server import GzipEncoderFactory
+ GZIP_ENCODER = GzipEncoderFactory()
+except ImportError:
+ GZIP_ENCODER = None
# TODO, cache gzip stuff
cache = {}
global cache
cache = {}
-def apply_gzip(request):
- accept_encoding = request.getHeader('accept-encoding')
- if accept_encoding:
- encodings = accept_encoding.split(',')
- for encoding in encodings:
- name = encoding.split(';')[0].strip()
- if name == 'gzip':
- request = GZipRequest(request)
- return request
-
class StaticEngine(static.File):
isLeaf = False
hit = util.HitCounter()
def __init__(self, *args, **kwargs):
static.File.__init__(self, *args, **kwargs)
-
+
def render(self, request):
self.hit(request)
- request = apply_gzip(request)
+# temporarily disabled -- seems to eat big pages
+# if GZIP_ENCODER:
+# request._encoder = GZIP_ENCODER.encoderForRequest(request) # HACK
return static.File.render(self, request)
@property
(self.hit,),
]
}
+
+ def directoryListing(self):
+ return error.ForbiddenResource()