10
10
capable of achieving basic tasks.
11
11
"""
12
12
13
- from concurrent .futures import as_completed , ThreadPoolExecutor
14
13
import logging
15
14
import random
15
+ from concurrent .futures import as_completed , ThreadPoolExecutor
16
+
16
17
import requests
17
- import threading
18
+
18
19
from hyper import HTTP20Connection , HTTP11Connection , HTTPConnection
19
20
from hyper .common .util import HTTPVersion
20
21
from hyper .contrib import HTTP20Adapter
21
22
22
23
logging .basicConfig (level = logging .INFO )
23
24
25
+
24
26
class TestHyperActuallyWorks (object ):
25
27
def test_abusing_nghttp2_org (self ):
26
28
"""
@@ -93,32 +95,32 @@ def do_one_page(path):
93
95
assert text_data
94
96
95
97
max_workers = len (paths )
96
- with ThreadPoolExecutor (max_workers = len ( paths ) ) as ex :
98
+ with ThreadPoolExecutor (max_workers = max_workers ) as ex :
97
99
futures = [ex .submit (do_one_page , p ) for p in paths ]
98
100
for f in as_completed (futures ):
99
101
f .result ()
100
102
101
- def test_hitting_http2bin_org (self ):
103
+ def test_hitting_nghttp2_org (self ):
102
104
"""
103
- This test function uses the requests adapter and requests to talk to http2bin .
105
+ This test function uses the requests adapter and requests to talk to nghttp2.org/httpbin .
104
106
"""
105
107
s = requests .Session ()
106
108
a = HTTP20Adapter ()
107
- s .mount ('https://http2bin ' , a )
108
- s .mount ('https://www.http2bin ' , a )
109
+ s .mount ('https://nghttp2 ' , a )
110
+ s .mount ('https://www.nghttp2 ' , a )
109
111
110
112
# Here are some nice URLs.
111
113
urls = [
112
- 'https://www.http2bin .org/' ,
113
- 'https://www.http2bin .org/ip' ,
114
- 'https://www.http2bin .org/user-agent' ,
115
- 'https://www.http2bin .org/headers' ,
116
- 'https://www.http2bin .org/get' ,
117
- 'https://http2bin .org/' ,
118
- 'https://http2bin .org/ip' ,
119
- 'https://http2bin .org/user-agent' ,
120
- 'https://http2bin .org/headers' ,
121
- 'https://http2bin .org/get' ,
114
+ 'https://www.nghttp2 .org/httpbin /' ,
115
+ 'https://www.nghttp2 .org/httpbin /ip' ,
116
+ 'https://www.nghttp2 .org/httpbin /user-agent' ,
117
+ 'https://www.nghttp2 .org/httpbin /headers' ,
118
+ 'https://www.nghttp2 .org/httpbin /get' ,
119
+ 'https://nghttp2 .org/httpbin /' ,
120
+ 'https://nghttp2 .org/httpbin /ip' ,
121
+ 'https://nghttp2 .org/httpbin /user-agent' ,
122
+ 'https://nghttp2 .org/httpbin /headers' ,
123
+ 'https://nghttp2 .org/httpbin /get' ,
122
124
]
123
125
124
126
# Go get everything.
@@ -132,7 +134,7 @@ def test_hitting_httpbin_org_http11(self):
132
134
"""
133
135
This test function uses hyper's HTTP/1.1 support to talk to httpbin
134
136
"""
135
- c = HTTP11Connection ('httpbin.org' )
137
+ c = HTTP11Connection ('httpbin.org:443 ' )
136
138
137
139
# Here are some nice URLs.
138
140
urls = [
0 commit comments