|
2 | 2 | from hyper.packages.hyperframe.frame import (
|
3 | 3 | Frame, DataFrame, RstStreamFrame, SettingsFrame,
|
4 | 4 | PushPromiseFrame, PingFrame, WindowUpdateFrame, HeadersFrame,
|
5 |
| - ContinuationFrame, BlockedFrame, GoAwayFrame, FRAME_MAX_LEN |
| 5 | + ContinuationFrame, BlockedFrame, GoAwayFrame, FRAME_MAX_LEN, FRAME_MAX_ALLOWED_LEN |
6 | 6 | )
|
7 | 7 | from hyper.packages.hpack.hpack_compat import Encoder, Decoder
|
8 | 8 | from hyper.http20.connection import HTTP20Connection
|
@@ -246,6 +246,65 @@ def test_connections_increment_send_window_properly(self):
|
246 | 246 |
|
247 | 247 | assert c._out_flow_control_window == 65535 + 1000
|
248 | 248 |
|
| 249 | + def test_connections_handle_resizing_max_frame_size_properly(self): |
| 250 | + sock = DummySocket() |
| 251 | + f = SettingsFrame(0) |
| 252 | + f.settings[SettingsFrame.SETTINGS_MAX_FRAME_SIZE] = 65536 # 2^16 |
| 253 | + c = HTTP20Connection('www.google.com') |
| 254 | + c._sock = sock |
| 255 | + |
| 256 | + # 'Receive' the SETTINGS frame. |
| 257 | + c.receive_frame(f) |
| 258 | + |
| 259 | + # Confirm that the setting is stored and the max frame size increased. |
| 260 | + assert c._settings[SettingsFrame.SETTINGS_MAX_FRAME_SIZE] == 65536 |
| 261 | + |
| 262 | + # Confirm we got a SETTINGS ACK. |
| 263 | + f2 = decode_frame(sock.queue[0]) |
| 264 | + assert isinstance(f2, SettingsFrame) |
| 265 | + assert f2.stream_id == 0 |
| 266 | + assert f2.flags == set(['ACK']) |
| 267 | + |
| 268 | + def test_connections_handle_too_small_max_frame_size_properly(self): |
| 269 | + sock = DummySocket() |
| 270 | + f = SettingsFrame(0) |
| 271 | + f.settings[SettingsFrame.SETTINGS_MAX_FRAME_SIZE] = 1024 |
| 272 | + c = HTTP20Connection('www.google.com') |
| 273 | + c._sock = sock |
| 274 | + |
| 275 | + # 'Receive' the SETTINGS frame. |
| 276 | + c.receive_frame(f) |
| 277 | + |
| 278 | + # The value advertised by an endpoint MUST be between 2^14 and |
| 279 | + # 2^24-1 octets. Confirm that the max frame size did not increase. |
| 280 | + assert c._settings[SettingsFrame.SETTINGS_MAX_FRAME_SIZE] == FRAME_MAX_LEN |
| 281 | + |
| 282 | + # Confirm we got a SETTINGS ACK. |
| 283 | + f2 = decode_frame(sock.queue[0]) |
| 284 | + assert isinstance(f2, SettingsFrame) |
| 285 | + assert f2.stream_id == 0 |
| 286 | + assert f2.flags == set(['ACK']) |
| 287 | + |
| 288 | + def test_connections_handle_too_big_max_frame_size_properly(self): |
| 289 | + sock = DummySocket() |
| 290 | + f = SettingsFrame(0) |
| 291 | + f.settings[SettingsFrame.SETTINGS_MAX_FRAME_SIZE] = 67108864 # 2^26 |
| 292 | + c = HTTP20Connection('www.google.com') |
| 293 | + c._sock = sock |
| 294 | + |
| 295 | + # 'Receive' the SETTINGS frame. |
| 296 | + c.receive_frame(f) |
| 297 | + |
| 298 | + # The value advertised by an endpoint MUST be between 2^14 and |
| 299 | + # 2^24-1 octets. Confirm that the max frame size did not increase. |
| 300 | + assert c._settings[SettingsFrame.SETTINGS_MAX_FRAME_SIZE] == FRAME_MAX_LEN |
| 301 | + |
| 302 | + # Confirm we got a SETTINGS ACK. |
| 303 | + f2 = decode_frame(sock.queue[0]) |
| 304 | + assert isinstance(f2, SettingsFrame) |
| 305 | + assert f2.stream_id == 0 |
| 306 | + assert f2.flags == set(['ACK']) |
| 307 | + |
249 | 308 | def test_connections_handle_resizing_header_tables_properly(self):
|
250 | 309 | sock = DummySocket()
|
251 | 310 | f = SettingsFrame(0)
|
|
0 commit comments