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

Commit 0837669

Browse files
committed
Merge pull request #220 from vfaronov/development
Use the right alphabet for HTTP2-Settings (fixes #219)
2 parents 40a7569 + c370c02 commit 0837669

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

hyper/http11/connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ def _add_upgrade_headers(self, headers):
264264
# Encode SETTINGS frame payload in Base64 and put into the HTTP-2 Settings header.
265265
http2_settings = SettingsFrame(0)
266266
http2_settings.settings[SettingsFrame.INITIAL_WINDOW_SIZE] = 65535
267-
headers[b'HTTP2-Settings'] = base64.b64encode(http2_settings.serialize_body())
267+
encoded_settings = base64.urlsafe_b64encode(http2_settings.serialize_body())
268+
headers[b'HTTP2-Settings'] = encoded_settings.rstrip(b'=')
268269

269270
def _send_body(self, body, body_type):
270271
"""

test/test_http11.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_basic_request(self):
116116
b"User-Agent: hyper\r\n"
117117
b"connection: Upgrade, HTTP2-Settings\r\n"
118118
b"upgrade: h2c\r\n"
119-
b"HTTP2-Settings: AAQAAP//\r\n"
119+
b"HTTP2-Settings: AAQAAP__\r\n"
120120
b"host: httpbin.org\r\n"
121121
b"\r\n"
122122
)
@@ -143,7 +143,7 @@ def test_iterable_header(self):
143143
b"Custom-field: test2\r\n"
144144
b"connection: Upgrade, HTTP2-Settings\r\n"
145145
b"upgrade: h2c\r\n"
146-
b"HTTP2-Settings: AAQAAP//\r\n"
146+
b"HTTP2-Settings: AAQAAP__\r\n"
147147
b"host: httpbin.org\r\n"
148148
b"\r\n"
149149
)
@@ -169,7 +169,7 @@ def test_proxy_request(self):
169169
b"User-Agent: hyper\r\n"
170170
b"connection: Upgrade, HTTP2-Settings\r\n"
171171
b"upgrade: h2c\r\n"
172-
b"HTTP2-Settings: AAQAAP//\r\n"
172+
b"HTTP2-Settings: AAQAAP__\r\n"
173173
b"host: httpbin.org\r\n"
174174
b"\r\n"
175175
)
@@ -193,7 +193,7 @@ def test_request_with_bytestring_body(self):
193193
b"User-Agent: hyper\r\n"
194194
b"connection: Upgrade, HTTP2-Settings\r\n"
195195
b"upgrade: h2c\r\n"
196-
b"HTTP2-Settings: AAQAAP//\r\n"
196+
b"HTTP2-Settings: AAQAAP__\r\n"
197197
b"content-length: 2\r\n"
198198
b"host: httpbin.org\r\n"
199199
b"\r\n"
@@ -225,7 +225,7 @@ def fake_fstat(*args):
225225
b"POST /post HTTP/1.1\r\n"
226226
b"connection: Upgrade, HTTP2-Settings\r\n"
227227
b"upgrade: h2c\r\n"
228-
b"HTTP2-Settings: AAQAAP//\r\n"
228+
b"HTTP2-Settings: AAQAAP__\r\n"
229229
b"content-length: 16\r\n"
230230
b"host: httpbin.org\r\n"
231231
b"\r\n"
@@ -253,7 +253,7 @@ def body():
253253
b"POST /post HTTP/1.1\r\n"
254254
b"connection: Upgrade, HTTP2-Settings\r\n"
255255
b"upgrade: h2c\r\n"
256-
b"HTTP2-Settings: AAQAAP//\r\n"
256+
b"HTTP2-Settings: AAQAAP__\r\n"
257257
b"transfer-encoding: chunked\r\n"
258258
b"host: httpbin.org\r\n"
259259
b"\r\n"
@@ -283,7 +283,7 @@ def body():
283283
b"content-length: 10\r\n"
284284
b"connection: Upgrade, HTTP2-Settings\r\n"
285285
b"upgrade: h2c\r\n"
286-
b"HTTP2-Settings: AAQAAP//\r\n"
286+
b"HTTP2-Settings: AAQAAP__\r\n"
287287
b"host: httpbin.org\r\n"
288288
b"\r\n"
289289
b"hitheresir"
@@ -310,7 +310,7 @@ def test_chunked_overrides_body(self):
310310
b"transfer-encoding: chunked\r\n"
311311
b"connection: Upgrade, HTTP2-Settings\r\n"
312312
b"upgrade: h2c\r\n"
313-
b"HTTP2-Settings: AAQAAP//\r\n"
313+
b"HTTP2-Settings: AAQAAP__\r\n"
314314
b"host: httpbin.org\r\n"
315315
b"\r\n"
316316
b"8\r\noneline\n\r\n"

0 commit comments

Comments
 (0)