@@ -38,16 +38,16 @@ def test_pycohttpparser_installs_correctly(self):
38
38
assert True
39
39
40
40
def test_initialization_no_port (self ):
41
- c = HTTP11Connection ('http2bin .org' )
41
+ c = HTTP11Connection ('httpbin .org' )
42
42
43
- assert c .host == 'http2bin .org'
43
+ assert c .host == 'httpbin .org'
44
44
assert c .port == 80
45
45
assert not c .secure
46
46
47
47
def test_initialization_inline_port (self ):
48
- c = HTTP11Connection ('http2bin .org:443' )
48
+ c = HTTP11Connection ('httpbin .org:443' )
49
49
50
- assert c .host == 'http2bin .org'
50
+ assert c .host == 'httpbin .org'
51
51
assert c .port == 443
52
52
assert c .secure
53
53
@@ -66,23 +66,26 @@ def test_can_override_security(self):
66
66
assert not c .secure
67
67
68
68
def test_basic_request (self ):
69
- c = HTTP11Connection ('http2bin .org' )
69
+ c = HTTP11Connection ('httpbin .org' )
70
70
c ._sock = sock = DummySocket ()
71
71
72
72
c .request ('GET' , '/get' , headers = {'User-Agent' : 'hyper' })
73
73
74
74
expected = (
75
75
b"GET /get HTTP/1.1\r \n "
76
76
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 "
78
81
b"\r \n "
79
82
)
80
83
received = b'' .join (sock .queue )
81
84
82
85
assert received == expected
83
86
84
87
def test_request_with_bytestring_body (self ):
85
- c = HTTP11Connection ('http2bin .org' )
88
+ c = HTTP11Connection ('httpbin .org' )
86
89
c ._sock = sock = DummySocket ()
87
90
88
91
c .request (
@@ -95,8 +98,11 @@ def test_request_with_bytestring_body(self):
95
98
expected = (
96
99
b"POST /post HTTP/1.1\r \n "
97
100
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 "
98
104
b"content-length: 2\r \n "
99
- b"host: http2bin .org\r \n "
105
+ b"host: httpbin .org\r \n "
100
106
b"\r \n "
101
107
b"hi"
102
108
)
@@ -116,16 +122,19 @@ def fake_fstat(*args):
116
122
117
123
try :
118
124
hyper .http11 .connection .os .fstat = fake_fstat
119
- c = HTTP11Connection ('http2bin .org' )
125
+ c = HTTP11Connection ('httpbin .org' )
120
126
c ._sock = sock = DummySocket ()
121
127
122
128
f = DummyFile (b'some binary data' )
123
129
c .request ('POST' , '/post' , body = f )
124
130
125
131
expected = (
126
132
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 "
127
136
b"content-length: 16\r \n "
128
- b"host: http2bin .org\r \n "
137
+ b"host: httpbin .org\r \n "
129
138
b"\r \n "
130
139
b"some binary data"
131
140
)
@@ -138,7 +147,7 @@ def fake_fstat(*args):
138
147
hyper .http11 .connection .os .fstat = old_fstat
139
148
140
149
def test_request_with_generator_body (self ):
141
- c = HTTP11Connection ('http2bin .org' )
150
+ c = HTTP11Connection ('httpbin .org' )
142
151
c ._sock = sock = DummySocket ()
143
152
def body ():
144
153
yield b'hi'
@@ -149,8 +158,11 @@ def body():
149
158
150
159
expected = (
151
160
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 "
152
164
b"transfer-encoding: chunked\r \n "
153
- b"host: http2bin .org\r \n "
165
+ b"host: httpbin .org\r \n "
154
166
b"\r \n "
155
167
b"2\r \n hi\r \n "
156
168
b"5\r \n there\r \n "
@@ -162,7 +174,7 @@ def body():
162
174
assert received == expected
163
175
164
176
def test_content_length_overrides_generator (self ):
165
- c = HTTP11Connection ('http2bin .org' )
177
+ c = HTTP11Connection ('httpbin .org' )
166
178
c ._sock = sock = DummySocket ()
167
179
def body ():
168
180
yield b'hi'
@@ -176,7 +188,10 @@ def body():
176
188
expected = (
177
189
b"POST /post HTTP/1.1\r \n "
178
190
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 "
180
195
b"\r \n "
181
196
b"hitheresir"
182
197
)
@@ -185,7 +200,7 @@ def body():
185
200
assert received == expected
186
201
187
202
def test_chunked_overrides_body (self ):
188
- c = HTTP11Connection ('http2bin .org' )
203
+ c = HTTP11Connection ('httpbin .org' )
189
204
c ._sock = sock = DummySocket ()
190
205
191
206
f = DummyFile (b'oneline\n anotherline' )
@@ -200,7 +215,10 @@ def test_chunked_overrides_body(self):
200
215
expected = (
201
216
b"POST /post HTTP/1.1\r \n "
202
217
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 "
204
222
b"\r \n "
205
223
b"8\r \n oneline\n \r \n "
206
224
b"b\r \n anotherline\r \n "
@@ -211,7 +229,7 @@ def test_chunked_overrides_body(self):
211
229
assert received == expected
212
230
213
231
def test_get_response (self ):
214
- c = HTTP11Connection ('http2bin .org' )
232
+ c = HTTP11Connection ('httpbin .org' )
215
233
c ._sock = sock = DummySocket ()
216
234
217
235
sock ._buffer = BytesIO (
@@ -234,7 +252,7 @@ def test_get_response(self):
234
252
assert r .read () == b''
235
253
236
254
def test_response_short_reads (self ):
237
- c = HTTP11Connection ('http2bin .org' )
255
+ c = HTTP11Connection ('httpbin .org' )
238
256
c ._sock = sock = DummySocket ()
239
257
240
258
sock ._buffer = BytesIO (
@@ -254,7 +272,7 @@ def test_response_short_reads(self):
254
272
assert r .read (5 ) == b''
255
273
256
274
def test_request_with_unicodestring_body (self ):
257
- c = HTTP11Connection ('http2bin .org' )
275
+ c = HTTP11Connection ('httpbin .org' )
258
276
c ._sock = DummySocket ()
259
277
260
278
with pytest .raises (ValueError ):
@@ -277,7 +295,7 @@ def fake_fstat(*args):
277
295
278
296
try :
279
297
hyper .http11 .connection .os .fstat = fake_fstat
280
- c = HTTP11Connection ('http2bin .org' )
298
+ c = HTTP11Connection ('httpbin .org' )
281
299
c ._sock = DummySocket ()
282
300
283
301
f = DummyFile (b'' )
@@ -290,7 +308,7 @@ def fake_fstat(*args):
290
308
hyper .http11 .connection .os .fstat = old_fstat
291
309
292
310
def test_request_with_unicode_generator_body (self ):
293
- c = HTTP11Connection ('http2bin .org' )
311
+ c = HTTP11Connection ('httpbin .org' )
294
312
c ._sock = DummySocket ()
295
313
def body ():
296
314
yield u'hi'
@@ -301,7 +319,7 @@ def body():
301
319
c .request ('POST' , '/post' , body = body ())
302
320
303
321
def test_content_length_overrides_generator_unicode (self ):
304
- c = HTTP11Connection ('http2bin .org' )
322
+ c = HTTP11Connection ('httpbin .org' )
305
323
c ._sock = DummySocket ()
306
324
def body ():
307
325
yield u'hi'
0 commit comments