Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Commit

Permalink
Fix decoding gzip
Browse files Browse the repository at this point in the history
This is how urllib3 does it.
  • Loading branch information
vfaronov committed Feb 1, 2018
1 parent cc6a3b5 commit 1456cda
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Added

Fixed
-----
- ``gzip``-encoded payloads are now decompressed more reliably.
- When `analyzing TCP streams`_, HTTPolice now uses a stricter heuristic
for detecting HTTP/1.x streams, producing fewer spurious `1006`_/`1009`_
notices.
Expand Down
5 changes: 2 additions & 3 deletions httpolice/codings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

"""Decoding content and transfer codings."""

import gzip
import io
import zlib

import brotli


def decode_gzip(data):
return gzip.GzipFile(fileobj=io.BytesIO(data)).read()
# Just ``decompress(data, 16 + zlib.MAX_WBITS)`` doesn't work.
return zlib.decompressobj(16 + zlib.MAX_WBITS).decompress(data)


def decode_deflate(data):
Expand Down

0 comments on commit 1456cda

Please sign in to comment.