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

Commit e734769

Browse files
committed
Merge branch 'development' into http11
2 parents d094d5c + fe2ce38 commit e734769

File tree

14 files changed

+125
-69
lines changed

14 files changed

+125
-69
lines changed

CONTRIBUTORS.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ In chronological order:
2525
- Fixed a bug where large or incomplete frames were not handled correctly.
2626
- Added hyper command-line tool.
2727
- General code cleanups.
28+
29+
- Jerome De Cuyper (@jdecuyper)
30+
31+
- Updated documentation and tests.
32+

HISTORY.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ Release History
44
Upcoming
55
--------
66

7+
*Bugfixes*
8+
9+
- Hyper now correctly handles 'never indexed' header fields. (`Issue #110`_)
10+
11+
.. _Issue #110: https://github.com/Lukasa/hyper/issues/110
12+
13+
0.2.1 (2015-03-29)
14+
------------------
15+
716
*New Features*
817

918
- There is now a `hyper` command-line client that supports making HTTP/2

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ improved speed, lower bandwidth usage, better connection management, and more.
1515

1616
from hyper import HTTP20Connection
1717

18-
conn = HTTP20Connection('twitter.com:443')
19-
conn.request('GET', '/')
18+
conn = HTTP20Connection('http2bin.org:443')
19+
conn.request('GET', '/get')
2020
resp = conn.getresponse()
2121

2222
print(resp.read())

docs/source/advanced.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ you decide you want to avoid keeping the connection open, you can use the
1616
:class:`HTTP20Connection <hyper.HTTP20Connection>` and
1717
:class:`HTTP11Connection <hyper.HTTP11Connection>` as context managers::
1818

19-
with HTTP20Connection('twitter.com:443') as conn:
20-
conn.request('GET', '/')
21-
data = conn.get_response().read()
19+
with HTTP20Connection('http2bin.org') as conn:
20+
conn.request('GET', '/get')
21+
data = conn.getresponse().read()
2222

2323
analyse(data)
2424

@@ -131,7 +131,7 @@ that always resizes the window in response to incoming data like this::
131131

132132
The *class* can then be plugged straight into a connection object::
133133

134-
HTTP20Connection('twitter.com:443', window_manager=StupidFlowControlManager)
134+
HTTP20Connection('http2bin.org', window_manager=StupidFlowControlManager)
135135

136136
Note that we don't plug an instance of the class in, we plug the class itself
137137
in. We do this because the connection object will spawn instances of the class

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
# built documents.
5656
#
5757
# The short X.Y version.
58-
version = '0.2.0'
58+
version = '0.2.1'
5959
# The full version, including alpha/beta/rc tags.
60-
release = '0.2.0'
60+
release = '0.2.1'
6161

6262
# The language for content autogenerated by Sphinx. Refer to documentation
6363
# for a list of supported languages.

docs/source/images/hyper-white.png

45.4 KB
Loading

docs/source/images/hyper-white.svg

Lines changed: 20 additions & 16 deletions
Loading

docs/source/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ improved speed, lower bandwidth usage, better connection management, and more.
1616

1717
from hyper import HTTP20Connection
1818

19-
conn = HTTP20Connection('twitter.com:443')
20-
conn.request('GET', '/')
21-
resp = conn.get_response()
19+
conn = HTTP20Connection('http2bin.org:443')
20+
conn.request('GET', '/get')
21+
resp = conn.getresponse()
2222

2323
print(resp.read())
2424

docs/source/quickstart.rst

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ With ``hyper`` installed, you can start making HTTP/2 requests. At this
5555
stage, ``hyper`` can only be used with services that *definitely* support
5656
HTTP/2. Before you begin, ensure that whichever service you're contacting
5757
definitely supports HTTP/2. For the rest of these examples, we'll use
58-
Twitter.
58+
http2bin.org, a HTTP/1.1 and HTTP/2 testing service.
5959

60-
Begin by getting the Twitter homepage::
60+
Begin by getting the homepage::
6161

6262
>>> from hyper import HTTP20Connection
63-
>>> c = HTTP20Connection('twitter.com:443')
63+
>>> c = HTTP20Connection('http2bin.org')
6464
>>> c.request('GET', '/')
6565
1
6666
>>> resp = c.get_response()
@@ -76,15 +76,16 @@ come back to it.
7676

7777
Once you've got the data, things diverge a little bit::
7878

79-
>>> resp.getheader('content-encoding')
80-
'deflate'
79+
>>> resp.header('content-type')
80+
'text/html; charset=utf-8'
8181
>>> resp.headers
82-
HTTPHeaderMap([(b'x-xss-protection', b'1; mode=block')...
82+
HTTPHeaderMap([('server', 'h2o/1.0.2-alpha1')...
8383
>>> resp.status
8484
200
8585

86-
We know that Twitter has compressed the response body. ``hyper`` will
87-
automatically decompress that body for you, no input required::
86+
If http2bin had compressed the response body. ``hyper`` would automatically
87+
decompress that body for you, no input required. This means you can always get
88+
the body by simply reading it::
8889

8990
>>> body = resp.read()
9091
b'<!DOCTYPE html>\n<!--[if IE 8]><html clas ....
@@ -101,13 +102,13 @@ the response from any of them, and switch between them using their stream IDs.
101102
For example::
102103

103104
>>> from hyper import HTTP20Connection
104-
>>> c = HTTP20Connection('twitter.com:443')
105-
>>> first = c.request('GET', '/')
106-
>>> second = c.request('GET', '/lukasaoz')
107-
>>> third = c.request('GET', '/about')
108-
>>> second_response = c.get_response(second)
109-
>>> first_response = c.get_response(first)
110-
>>> third_response = c.get_response(third)
105+
>>> c = HTTP20Connection('http2bin.org')
106+
>>> first = c.request('GET', '/get')
107+
>>> second = c.request('POST', '/post', data='key=value')
108+
>>> third = c.request('GET', '/ip')
109+
>>> second_response = c.getresponse(second)
110+
>>> first_response = c.getresponse(first)
111+
>>> third_response = c.getresponse(third)
111112

112113
``hyper`` will ensure that each response is matched to the correct request.
113114

@@ -160,8 +161,8 @@ HTTP/2. Once you've worked that out, you can get started straight away::
160161
>>> import requests
161162
>>> from hyper.contrib import HTTP20Adapter
162163
>>> s = requests.Session()
163-
>>> s.mount('https://twitter.com', HTTP20Adapter())
164-
>>> r = s.get('https://twitter.com')
164+
>>> s.mount('https://http2bin.org', HTTP20Adapter())
165+
>>> r = s.get('https://http2bin.org/get')
165166
>>> print(r.status_code)
166167
200
167168

@@ -173,8 +174,8 @@ you away from HTTP/2. Make sure you install the adapter for all the hostnames
173174
you're interested in::
174175

175176
>>> a = HTTP20Adapter()
176-
>>> s.mount('https://twitter.com', a)
177-
>>> s.mount('https://www.twitter.com', a)
177+
>>> s.mount('https://http2bin.org', a)
178+
>>> s.mount('https://www.http2bin.org', a)
178179

179180
.. _requests: http://python-requests.org/
180181

0 commit comments

Comments
 (0)