|
5 | 5 | from hyperframe.frame import ( |
6 | 6 | Frame, DataFrame, RstStreamFrame, SettingsFrame, PushPromiseFrame, |
7 | 7 | WindowUpdateFrame, HeadersFrame, ContinuationFrame, GoAwayFrame, |
8 | | - FRAME_MAX_ALLOWED_LEN |
| 8 | + PingFrame, FRAME_MAX_ALLOWED_LEN |
9 | 9 | ) |
10 | 10 | from hpack.hpack_compat import Encoder |
11 | 11 | from hyper.http20.connection import HTTP20Connection |
|
15 | 15 | combine_repeated_headers, split_repeated_headers, h2_safe_headers |
16 | 16 | ) |
17 | 17 | from hyper.common.headers import HTTPHeaderMap |
| 18 | +from hyper.common.util import to_bytestring |
18 | 19 | from hyper.compat import zlib_compressobj, is_py2 |
19 | 20 | from hyper.contrib import HTTP20Adapter |
20 | 21 | import hyper.http20.errors as errors |
@@ -80,6 +81,22 @@ def test_connections_can_parse_ipv6_hosts_and_ports(self): |
80 | 81 | assert c.proxy_host == 'ffff:aaaa::1' |
81 | 82 | assert c.proxy_port == 8443 |
82 | 83 |
|
| 84 | + def test_ping(self, frame_buffer): |
| 85 | + def data_callback(chunk, **kwargs): |
| 86 | + frame_buffer.add_data(chunk) |
| 87 | + |
| 88 | + c = HTTP20Connection('www.google.com') |
| 89 | + c._sock = DummySocket() |
| 90 | + c._send_cb = data_callback |
| 91 | + opaque = '00000000' |
| 92 | + c.ping(opaque) |
| 93 | + |
| 94 | + frames = list(frame_buffer) |
| 95 | + assert len(frames) == 1 |
| 96 | + f = frames[0] |
| 97 | + assert isinstance(f, PingFrame) |
| 98 | + assert f.opaque_data == to_bytestring(opaque) |
| 99 | + |
83 | 100 | def test_putrequest_establishes_new_stream(self): |
84 | 101 | c = HTTP20Connection("www.google.com") |
85 | 102 |
|
|
0 commit comments