Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Commit b6f5aee

Browse files
committed
Document automatic decompression.
1 parent 2c97def commit b6f5aee

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

HISTORY.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ X.X.X (XXXX-XX-XX)
1010
- Stopped HTTP/2.0 special headers appearing in the response headers.
1111
(`Issue #16`_)
1212
- `HTTP20Connection` objects are now context managers. (`Issue #13`_)
13+
- Response bodies are automatically decompressed. (`Issue #20`_)
1314

1415

1516
.. _Issue #12: https://github.com/Lukasa/hyper/issues/12
1617
.. _Issue #16: https://github.com/Lukasa/hyper/issues/16
1718
.. _Issue #13: https://github.com/Lukasa/hyper/issues/13
19+
.. _Issue #20: https://github.com/Lukasa/hyper/issues/20
1820

1921
0.0.1 (2014-02-11)
2022
++++++++++++++++++

docs/source/advanced.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,16 @@ a 'streaming' upload by providing a file-like object to the 'data' parameter.
3333
This will cause ``hyper`` to read the data in 1kB at a time and send it to the
3434
remote server. You _must_ set an accurate Content-Length header when you do
3535
this, as ``hyper`` won't set it for you.
36+
37+
Content Decompression
38+
---------------------
39+
40+
In HTTP/2.0 it's mandatory that user-agents support receiving responses that
41+
have their bodies compressed. As demonstrated in the quickstart guide,
42+
``hyper`` transparently implements this decompression, meaning that responses
43+
are automatically decompressed for you. If you don't want this to happen,
44+
you can turn it off by passing the ``decode_content`` parameter to
45+
:meth:`read() <hyper.HTTP20Response.read>`, like this::
46+
47+
>>> resp.read(decode_content=False)
48+
b'\xc9...'

docs/source/quickstart.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,10 @@ Once you've got the data, things continue to behave exactly like
7272
>>> resp.status
7373
200
7474

75-
Based on the ``Content-Encoding`` header, we know that the body is compressed.
76-
Currently, ``hyper`` doesn't support decoding that body, so you'll need to do
77-
it yourself::
75+
We know that Twitter has compressed the response body. ``hyper`` will
76+
automatically decompress that body for you, no input required::
7877

7978
>>> body = resp.read()
80-
>>> import zlib
81-
>>> zlib.decompress(body)
8279
b'<!DOCTYPE html>\n<!--[if IE 8]><html clas ....
8380

8481
That's all it takes.

0 commit comments

Comments
 (0)