mercurial/hgweb/protocol.py
changeset 30358 38130a0bbb99
parent 30206 d105195436c0
child 30366 038547a14d85
equal deleted inserted replaced
30357:5925bda42dbd 30358:38130a0bbb99
    86 
    86 
    87     def compresschunks(self, chunks):
    87     def compresschunks(self, chunks):
    88         # Don't allow untrusted settings because disabling compression or
    88         # Don't allow untrusted settings because disabling compression or
    89         # setting a very high compression level could lead to flooding
    89         # setting a very high compression level could lead to flooding
    90         # the server's network or CPU.
    90         # the server's network or CPU.
    91         z = zlib.compressobj(self.ui.configint('server', 'zliblevel', -1))
    91         opts = {'level': self.ui.configint('server', 'zliblevel', -1)}
    92         for chunk in chunks:
    92         return util.compengines['zlib'].compressstream(chunks, opts)
    93             data = z.compress(chunk)
       
    94             # Not all calls to compress() emit data. It is cheaper to inspect
       
    95             # that here than to send it via the generator.
       
    96             if data:
       
    97                 yield data
       
    98         yield z.flush()
       
    99 
    93 
   100     def _client(self):
    94     def _client(self):
   101         return 'remote:%s:%s:%s' % (
    95         return 'remote:%s:%s:%s' % (
   102             self.req.env.get('wsgi.url_scheme') or 'http',
    96             self.req.env.get('wsgi.url_scheme') or 'http',
   103             urlreq.quote(self.req.env.get('REMOTE_HOST', '')),
    97             urlreq.quote(self.req.env.get('REMOTE_HOST', '')),