mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-30 12:53:08 +02:00
Send uncompressed length in a custom header, if available, when using gzip transfer encoding
This commit is contained in:
parent
673eee9f5a
commit
da7ffcaf82
2 changed files with 3 additions and 0 deletions
|
|
@ -595,6 +595,8 @@ def finalize_output(self, output, request, is_http1):
|
|||
outheaders.set('Accept-Ranges', 'bytes', replace_all=True)
|
||||
if compressible and not ranges:
|
||||
outheaders.set('Content-Encoding', 'gzip', replace_all=True)
|
||||
if getattr(output, 'content_length', None):
|
||||
outheaders.set('Calibre-Uncompressed-Length', '%d' % output.content_length)
|
||||
output = GeneratedOutput(compress_readable_output(output.src_file), etag=output.etag)
|
||||
if output.content_length is not None and not compressible and not ranges:
|
||||
outheaders.set('Content-Length', '%d' % output.content_length, replace_all=True)
|
||||
|
|
|
|||
|
|
@ -313,6 +313,7 @@ def handler(conn):
|
|||
conn = server.connect()
|
||||
conn.request('GET', '/an_etagged_path', headers={'Accept-Encoding':'gzip'})
|
||||
r = conn.getresponse()
|
||||
self.ae(str(len(raw)), r.getheader('Calibre-Uncompressed-Length'))
|
||||
self.ae(r.status, httplib.OK), self.ae(zlib.decompress(r.read(), 16+zlib.MAX_WBITS), raw)
|
||||
|
||||
# Test getting a filesystem file
|
||||
|
|
|
|||
Loading…
Reference in a new issue