本文整理匯總了Python中hyper.http20.frame.Frame.parse_frame_header方法的典型用法代碼示例。如果您正苦於以下問題:Python Frame.parse_frame_header方法的具體用法?Python Frame.parse_frame_header怎麽用?Python Frame.parse_frame_header使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hyper.http20.frame.Frame
的用法示例。
在下文中一共展示了Frame.parse_frame_header方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_rst_stream_frame_parses_properly
# 需要導入模塊: from hyper.http20.frame import Frame [as 別名]
# 或者: from hyper.http20.frame.Frame import parse_frame_header [as 別名]
def test_rst_stream_frame_parses_properly(self):
s = b'\x00\x04\x03\x00\x00\x00\x00\x01\x00\x00\x01\xa4'
f, length = Frame.parse_frame_header(s[:8])
f.parse_body(s[8:8 + length])
assert isinstance(f, RstStreamFrame)
assert f.flags == set()
assert f.error_code == 420
示例2: test_data_frame_parses_properly
# 需要導入模塊: from hyper.http20.frame import Frame [as 別名]
# 或者: from hyper.http20.frame.Frame import parse_frame_header [as 別名]
def test_data_frame_parses_properly(self):
s = b'\x00\x08\x00\x01\x00\x00\x00\x01testdata'
f, length = Frame.parse_frame_header(s[:8])
f.parse_body(s[8:8 + length])
assert isinstance(f, DataFrame)
assert f.flags == set(['END_STREAM'])
assert f.data == b'testdata'
示例3: test_priority_frame_parses_properly
# 需要導入模塊: from hyper.http20.frame import Frame [as 別名]
# 或者: from hyper.http20.frame.Frame import parse_frame_header [as 別名]
def test_priority_frame_parses_properly(self):
s = b'\x00\x04\x02\x00\x00\x00\x00\x01\x00\x00\x00\xff'
f, length = Frame.parse_frame_header(s[:8])
f.parse_body(s[8:8 + length])
assert isinstance(f, PriorityFrame)
assert f.flags == set()
assert f.priority == 0xFF
示例4: test_ping_frame_parses_properly
# 需要導入模塊: from hyper.http20.frame import Frame [as 別名]
# 或者: from hyper.http20.frame.Frame import parse_frame_header [as 別名]
def test_ping_frame_parses_properly(self):
s = b'\x00\x08\x06\x01\x00\x00\x00\x00\x01\x02\x00\x00\x00\x00\x00\x00'
f, length = Frame.parse_frame_header(s[:8])
f.parse_body(s[8:8 + length])
assert isinstance(f, PingFrame)
assert f.flags == set(['ACK'])
assert f.opaque_data == b'\x01\x02\x00\x00\x00\x00\x00\x00'
示例5: test_continuation_frame_parses_properly
# 需要導入模塊: from hyper.http20.frame import Frame [as 別名]
# 或者: from hyper.http20.frame.Frame import parse_frame_header [as 別名]
def test_continuation_frame_parses_properly(self):
s = b'\x00\x0B\x0A\x04\x00\x00\x00\x01hello world'
f, length = Frame.parse_frame_header(s[:8])
f.parse_body(s[8:8 + length])
assert isinstance(f, ContinuationFrame)
assert f.flags == set(['END_HEADERS'])
assert f.data == b'hello world'
示例6: test_windowupdate_frame_parses_properly
# 需要導入模塊: from hyper.http20.frame import Frame [as 別名]
# 或者: from hyper.http20.frame.Frame import parse_frame_header [as 別名]
def test_windowupdate_frame_parses_properly(self):
s = b'\x00\x04\x09\x00\x00\x00\x00\x00\x00\x00\x02\x00'
f, length = Frame.parse_frame_header(s[:8])
f.parse_body(s[8:8 + length])
assert isinstance(f, WindowUpdateFrame)
assert f.flags == set()
assert f.window_increment == 512
示例7: test_headers_frame_parses_properly
# 需要導入模塊: from hyper.http20.frame import Frame [as 別名]
# 或者: from hyper.http20.frame.Frame import parse_frame_header [as 別名]
def test_headers_frame_parses_properly(self):
s = b"\x00\x0F\x01\x0D\x00\x00\x00\x01" + b"\x40\x00\x00\x01" + b"hello world"
f, length = Frame.parse_frame_header(s[:8])
f.parse_body(s[8 : 8 + length])
assert isinstance(f, HeadersFrame)
assert f.flags == set(["END_STREAM", "END_HEADERS", "PRIORITY"])
assert f.priority == (2 ** 30) + 1
assert f.data == b"hello world"
示例8: test_headers_frame_parses_properly
# 需要導入模塊: from hyper.http20.frame import Frame [as 別名]
# 或者: from hyper.http20.frame.Frame import parse_frame_header [as 別名]
def test_headers_frame_parses_properly(self):
s = (
b'\x00\x0F\x01\x0D\x00\x00\x00\x01' +
b'\x40\x00\x00\x01' +
b'hello world'
)
f, length = Frame.parse_frame_header(s[:8])
f.parse_body(s[8:8 + length])
assert isinstance(f, HeadersFrame)
assert f.flags == set(['END_STREAM', 'END_HEADERS', 'PRIORITY'])
assert f.priority == (2 ** 30) + 1
assert f.data == b'hello world'
示例9: test_goaway_frame_parses_properly
# 需要導入模塊: from hyper.http20.frame import Frame [as 別名]
# 或者: from hyper.http20.frame.Frame import parse_frame_header [as 別名]
def test_goaway_frame_parses_properly(self):
s = (
b'\x00\x0D\x07\x00\x00\x00\x00\x00' + # Frame header
b'\x00\x00\x00\x40' + # Last Stream ID
b'\x00\x00\x00\x20' + # Error Code
b'hello' # Additional data
)
f, length = Frame.parse_frame_header(s[:8])
f.parse_body(s[8:8 + length])
assert isinstance(f, GoAwayFrame)
assert f.flags == set()
assert f.additional_data == b'hello'
示例10: test_settings_frame_parses_properly
# 需要導入模塊: from hyper.http20.frame import Frame [as 別名]
# 或者: from hyper.http20.frame.Frame import parse_frame_header [as 別名]
def test_settings_frame_parses_properly(self):
s = (
b'\x00\x28\x04\x01\x00\x00\x00\x00' + # Frame header
b'\x00\x00\x00\x01\x00\x00\x10\x00' + # HEADER_TABLE_SIZE
b'\x00\x00\x00\x02\x00\x00\x00\x00' + # ENABLE_PUSH
b'\x00\x00\x00\x04\x00\x00\x00\x64' + # MAX_CONCURRENT_STREAMS
b'\x00\x00\x00\x0A\x00\x00\x00\x01' + # FLOW_CONTROL_OPTIONS
b'\x00\x00\x00\x07\x00\x00\xFF\xFF' # INITIAL_WINDOW_SIZE
)
f, length = Frame.parse_frame_header(s[:8])
f.parse_body(s[8:8 + length])
assert isinstance(f, SettingsFrame)
assert f.flags == set(['ACK'])
assert f.settings == {
SettingsFrame.HEADER_TABLE_SIZE: 4096,
SettingsFrame.ENABLE_PUSH: 0,
SettingsFrame.MAX_CONCURRENT_STREAMS: 100,
SettingsFrame.INITIAL_WINDOW_SIZE: 65535,
SettingsFrame.FLOW_CONTROL_OPTIONS: 1,
}
示例11: decode_frame
# 需要導入模塊: from hyper.http20.frame import Frame [as 別名]
# 或者: from hyper.http20.frame.Frame import parse_frame_header [as 別名]
def decode_frame(frame_data):
f, length = Frame.parse_frame_header(frame_data[:8])
f.parse_body(frame_data[8 : 8 + length])
assert 8 + length == len(frame_data)
return f
示例12: decode_frame
# 需要導入模塊: from hyper.http20.frame import Frame [as 別名]
# 或者: from hyper.http20.frame.Frame import parse_frame_header [as 別名]
def decode_frame(frame_data):
f, length = Frame.parse_frame_header(frame_data[:9])
f.parse_body(memoryview(frame_data[9:9 + length]))
assert 9 + length == len(frame_data)
return f