@@ -38,16 +38,16 @@ def test_pycohttpparser_installs_correctly(self):
3838 assert True
3939
4040 def test_initialization_no_port (self ):
41- c = HTTP11Connection ('http2bin .org' )
41+ c = HTTP11Connection ('httpbin .org' )
4242
43- assert c .host == 'http2bin .org'
43+ assert c .host == 'httpbin .org'
4444 assert c .port == 80
4545 assert not c .secure
4646
4747 def test_initialization_inline_port (self ):
48- c = HTTP11Connection ('http2bin .org:443' )
48+ c = HTTP11Connection ('httpbin .org:443' )
4949
50- assert c .host == 'http2bin .org'
50+ assert c .host == 'httpbin .org'
5151 assert c .port == 443
5252 assert c .secure
5353
@@ -66,23 +66,26 @@ def test_can_override_security(self):
6666 assert not c .secure
6767
6868 def test_basic_request (self ):
69- c = HTTP11Connection ('http2bin .org' )
69+ c = HTTP11Connection ('httpbin .org' )
7070 c ._sock = sock = DummySocket ()
7171
7272 c .request ('GET' , '/get' , headers = {'User-Agent' : 'hyper' })
7373
7474 expected = (
7575 b"GET /get HTTP/1.1\r \n "
7676 b"User-Agent: hyper\r \n "
77- b"host: http2bin.org\r \n "
77+ b"connection: Upgrade, HTTP2-Settings\r \n "
78+ b"upgrade: h2c\r \n "
79+ b"HTTP2-Settings: AAQAAP//\r \n "
80+ b"host: httpbin.org\r \n "
7881 b"\r \n "
7982 )
8083 received = b'' .join (sock .queue )
8184
8285 assert received == expected
8386
8487 def test_request_with_bytestring_body (self ):
85- c = HTTP11Connection ('http2bin .org' )
88+ c = HTTP11Connection ('httpbin .org' )
8689 c ._sock = sock = DummySocket ()
8790
8891 c .request (
@@ -95,8 +98,11 @@ def test_request_with_bytestring_body(self):
9598 expected = (
9699 b"POST /post HTTP/1.1\r \n "
97100 b"User-Agent: hyper\r \n "
101+ b"connection: Upgrade, HTTP2-Settings\r \n "
102+ b"upgrade: h2c\r \n "
103+ b"HTTP2-Settings: AAQAAP//\r \n "
98104 b"content-length: 2\r \n "
99- b"host: http2bin .org\r \n "
105+ b"host: httpbin .org\r \n "
100106 b"\r \n "
101107 b"hi"
102108 )
@@ -116,16 +122,19 @@ def fake_fstat(*args):
116122
117123 try :
118124 hyper .http11 .connection .os .fstat = fake_fstat
119- c = HTTP11Connection ('http2bin .org' )
125+ c = HTTP11Connection ('httpbin .org' )
120126 c ._sock = sock = DummySocket ()
121127
122128 f = DummyFile (b'some binary data' )
123129 c .request ('POST' , '/post' , body = f )
124130
125131 expected = (
126132 b"POST /post HTTP/1.1\r \n "
133+ b"connection: Upgrade, HTTP2-Settings\r \n "
134+ b"upgrade: h2c\r \n "
135+ b"HTTP2-Settings: AAQAAP//\r \n "
127136 b"content-length: 16\r \n "
128- b"host: http2bin .org\r \n "
137+ b"host: httpbin .org\r \n "
129138 b"\r \n "
130139 b"some binary data"
131140 )
@@ -138,7 +147,7 @@ def fake_fstat(*args):
138147 hyper .http11 .connection .os .fstat = old_fstat
139148
140149 def test_request_with_generator_body (self ):
141- c = HTTP11Connection ('http2bin .org' )
150+ c = HTTP11Connection ('httpbin .org' )
142151 c ._sock = sock = DummySocket ()
143152 def body ():
144153 yield b'hi'
@@ -149,8 +158,11 @@ def body():
149158
150159 expected = (
151160 b"POST /post HTTP/1.1\r \n "
161+ b"connection: Upgrade, HTTP2-Settings\r \n "
162+ b"upgrade: h2c\r \n "
163+ b"HTTP2-Settings: AAQAAP//\r \n "
152164 b"transfer-encoding: chunked\r \n "
153- b"host: http2bin .org\r \n "
165+ b"host: httpbin .org\r \n "
154166 b"\r \n "
155167 b"2\r \n hi\r \n "
156168 b"5\r \n there\r \n "
@@ -162,7 +174,7 @@ def body():
162174 assert received == expected
163175
164176 def test_content_length_overrides_generator (self ):
165- c = HTTP11Connection ('http2bin .org' )
177+ c = HTTP11Connection ('httpbin .org' )
166178 c ._sock = sock = DummySocket ()
167179 def body ():
168180 yield b'hi'
@@ -176,7 +188,10 @@ def body():
176188 expected = (
177189 b"POST /post HTTP/1.1\r \n "
178190 b"content-length: 10\r \n "
179- b"host: http2bin.org\r \n "
191+ b"connection: Upgrade, HTTP2-Settings\r \n "
192+ b"upgrade: h2c\r \n "
193+ b"HTTP2-Settings: AAQAAP//\r \n "
194+ b"host: httpbin.org\r \n "
180195 b"\r \n "
181196 b"hitheresir"
182197 )
@@ -185,7 +200,7 @@ def body():
185200 assert received == expected
186201
187202 def test_chunked_overrides_body (self ):
188- c = HTTP11Connection ('http2bin .org' )
203+ c = HTTP11Connection ('httpbin .org' )
189204 c ._sock = sock = DummySocket ()
190205
191206 f = DummyFile (b'oneline\n anotherline' )
@@ -200,7 +215,10 @@ def test_chunked_overrides_body(self):
200215 expected = (
201216 b"POST /post HTTP/1.1\r \n "
202217 b"transfer-encoding: chunked\r \n "
203- b"host: http2bin.org\r \n "
218+ b"connection: Upgrade, HTTP2-Settings\r \n "
219+ b"upgrade: h2c\r \n "
220+ b"HTTP2-Settings: AAQAAP//\r \n "
221+ b"host: httpbin.org\r \n "
204222 b"\r \n "
205223 b"8\r \n oneline\n \r \n "
206224 b"b\r \n anotherline\r \n "
@@ -211,7 +229,7 @@ def test_chunked_overrides_body(self):
211229 assert received == expected
212230
213231 def test_get_response (self ):
214- c = HTTP11Connection ('http2bin .org' )
232+ c = HTTP11Connection ('httpbin .org' )
215233 c ._sock = sock = DummySocket ()
216234
217235 sock ._buffer = BytesIO (
@@ -234,7 +252,7 @@ def test_get_response(self):
234252 assert r .read () == b''
235253
236254 def test_response_short_reads (self ):
237- c = HTTP11Connection ('http2bin .org' )
255+ c = HTTP11Connection ('httpbin .org' )
238256 c ._sock = sock = DummySocket ()
239257
240258 sock ._buffer = BytesIO (
@@ -254,7 +272,7 @@ def test_response_short_reads(self):
254272 assert r .read (5 ) == b''
255273
256274 def test_request_with_unicodestring_body (self ):
257- c = HTTP11Connection ('http2bin .org' )
275+ c = HTTP11Connection ('httpbin .org' )
258276 c ._sock = DummySocket ()
259277
260278 with pytest .raises (ValueError ):
@@ -277,7 +295,7 @@ def fake_fstat(*args):
277295
278296 try :
279297 hyper .http11 .connection .os .fstat = fake_fstat
280- c = HTTP11Connection ('http2bin .org' )
298+ c = HTTP11Connection ('httpbin .org' )
281299 c ._sock = DummySocket ()
282300
283301 f = DummyFile (b'' )
@@ -290,7 +308,7 @@ def fake_fstat(*args):
290308 hyper .http11 .connection .os .fstat = old_fstat
291309
292310 def test_request_with_unicode_generator_body (self ):
293- c = HTTP11Connection ('http2bin .org' )
311+ c = HTTP11Connection ('httpbin .org' )
294312 c ._sock = DummySocket ()
295313 def body ():
296314 yield u'hi'
@@ -301,7 +319,7 @@ def body():
301319 c .request ('POST' , '/post' , body = body ())
302320
303321 def test_content_length_overrides_generator_unicode (self ):
304- c = HTTP11Connection ('http2bin .org' )
322+ c = HTTP11Connection ('httpbin .org' )
305323 c ._sock = DummySocket ()
306324 def body ():
307325 yield u'hi'
0 commit comments