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

Commit ae841cb

Browse files
committed
Stop using Twitter for documentation examples.
1 parent ec7aedc commit ae841cb

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

docs/source/advanced.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ very confident you won't need the connection again anytime soon. However, if
1515
you decide you want to avoid keeping the connection open, you can use the
1616
:class:`HTTP20Connection <hyper.HTTP20Connection>` as a context manager::
1717

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

2222
analyse(data)

docs/source/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ 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', '/')
19+
conn = HTTP20Connection('http2bin.org:443')
20+
conn.request('GET', '/get')
2121
resp = conn.getresponse()
2222

2323
print(resp.read())

docs/source/quickstart.rst

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

58-
Begin by getting the Twitter homepage::
58+
Begin by getting the homepage::
5959

6060
>>> from hyper import HTTP20Connection
61-
>>> c = HTTP20Connection('twitter.com:443')
61+
>>> c = HTTP20Connection('http2bin.org')
6262
>>> c.request('GET', '/')
6363
1
6464
>>> resp = c.getresponse()
@@ -75,15 +75,16 @@ come back to it.
7575
Once you've got the data, things continue to behave exactly like
7676
``http.client``::
7777

78-
>>> resp.getheader('content-encoding')
79-
'deflate'
78+
>>> resp.getheader('content-type')
79+
'text/html; charset=utf-8'
8080
>>> resp.getheaders()
81-
[('x-xss-protection', '1; mode=block')...
81+
[('server', 'h2o/1.0.2-alpha1')...
8282
>>> resp.status
8383
200
8484

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

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

102103
>>> from hyper import HTTP20Connection
103-
>>> c = HTTP20Connection('twitter.com:443')
104-
>>> first = c.request('GET', '/')
105-
>>> second = c.request('GET', '/lukasaoz')
106-
>>> third = c.request('GET', '/about')
104+
>>> c = HTTP20Connection('http2bin.org')
105+
>>> first = c.request('GET', '/get')
106+
>>> second = c.request('POST', '/post', data='key=value')
107+
>>> third = c.request('GET', '/ip')
107108
>>> second_response = c.getresponse(second)
108109
>>> first_response = c.getresponse(first)
109110
>>> third_response = c.getresponse(third)
@@ -124,8 +125,8 @@ HTTP/2. Once you've worked that out, you can get started straight away::
124125
>>> import requests
125126
>>> from hyper.contrib import HTTP20Adapter
126127
>>> s = requests.Session()
127-
>>> s.mount('https://twitter.com', HTTP20Adapter())
128-
>>> r = s.get('https://twitter.com')
128+
>>> s.mount('https://http2bin.org', HTTP20Adapter())
129+
>>> r = s.get('https://http2bin.org/get')
129130
>>> print(r.status_code)
130131
200
131132

0 commit comments

Comments
 (0)