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

Commit add5304

Browse files
committed
Mention the Requests transport adapter.
1 parent b6f5aee commit add5304

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ X.X.X (XXXX-XX-XX)
1111
(`Issue #16`_)
1212
- `HTTP20Connection` objects are now context managers. (`Issue #13`_)
1313
- Response bodies are automatically decompressed. (`Issue #20`_)
14+
- Provide a requests transport adapter. (`Issue #19`_)
15+
- Fix the build status indicator. (`Issue #22`_)
1416

1517

1618
.. _Issue #12: https://github.com/Lukasa/hyper/issues/12
1719
.. _Issue #16: https://github.com/Lukasa/hyper/issues/16
1820
.. _Issue #13: https://github.com/Lukasa/hyper/issues/13
1921
.. _Issue #20: https://github.com/Lukasa/hyper/issues/20
22+
.. _Issue #19: https://github.com/Lukasa/hyper/issues/19
23+
.. _Issue #22: https://github.com/Lukasa/hyper/issues/22
2024

2125
0.0.1 (2014-02-11)
2226
++++++++++++++++++

docs/source/quickstart.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,35 @@ For example::
9999
>>> third_response = c.getresponse(third)
100100

101101
``hyper`` will ensure that each response is matched to the correct request.
102+
103+
Requests Integration
104+
--------------------
105+
106+
Do you like `requests`_? Of course you do, everyone does! It's a shame that
107+
requests doesn't support HTTP/2.0 though. To rectify that oversight, ``hyper``
108+
provides a transport adapter that can be plugged directly into Requests, giving
109+
it instant HTTP/2.0 support.
110+
111+
All you have to do is identify a host that you'd like to communicate with over
112+
HTTP/2.0. Once you've worked that out, you can get started straight away::
113+
114+
>>> import requests
115+
>>> from hyper.contrib import HTTP20Adapter
116+
>>> s = requests.Session()
117+
>>> s.mount('https://twitter.com', HTTP20Adapter())
118+
>>> r = s.get('https://twitter.com')
119+
>>> print(r.status_code)
120+
200
121+
122+
This transport adapter is subject to all of the limitations that apply to
123+
``hyper``, and provides all of the goodness of requests.
124+
125+
A quick warning: some hosts will redirect to new hostnames, which may redirect
126+
you away from HTTP/2.0. Make sure you install the adapter for all the hostnames
127+
you're interested in::
128+
129+
>>> a = HTTP20Adapter()
130+
>>> s.mount('https://twitter.com', a)
131+
>>> s.mount('https://www.twitter.com', a)
132+
133+
.. _requests: http://python-requests.org/

0 commit comments

Comments
 (0)