[PATCH 10 of 11] hgweb: use compression engine API for zlib compression
Gregory Szorc
gregory.szorc at gmail.com
Tue Nov 1 20:08:43 EDT 2016
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1477160356 25200
# Sat Oct 22 11:19:16 2016 -0700
# Node ID fc426af4f25c3403703e913ccb4a6865865fcb02
# Parent 03555032b7e3bc7192fd8bebf6af3f05b1e70516
hgweb: use compression engine API for zlib compression
More low-level compression code elimination because we now have nice
APIs.
diff --git a/mercurial/hgweb/protocol.py b/mercurial/hgweb/protocol.py
--- a/mercurial/hgweb/protocol.py
+++ b/mercurial/hgweb/protocol.py
@@ -83,24 +83,18 @@ class webproto(wireproto.abstractserverp
yield chunk
return self.compresschunks(getchunks())
def compresschunks(self, chunks):
# Don't allow untrusted settings because disabling compression or
# setting a very high compression level could lead to flooding
# the server's network or CPU.
- z = zlib.compressobj(self.ui.configint('server', 'zliblevel', -1))
- for chunk in chunks:
- data = z.compress(chunk)
- # Not all calls to compress() emit data. It is cheaper to inspect
- # that here than to send it via the generator.
- if data:
- yield data
- yield z.flush()
+ opts = {'level': self.ui.configint('server', 'zliblevel', -1)}
+ return util.compressionengines['zlib'].compressstream(chunks, opts)
def _client(self):
return 'remote:%s:%s:%s' % (
self.req.env.get('wsgi.url_scheme') or 'http',
urlreq.quote(self.req.env.get('REMOTE_HOST', '')),
urlreq.quote(self.req.env.get('REMOTE_USER', '')))
def iscmd(cmd):
More information about the Mercurial-devel
mailing list