本文整理汇总了Python中hpack.hpack.Encoder.header_table_size方法的典型用法代码示例。如果您正苦于以下问题:Python Encoder.header_table_size方法的具体用法?Python Encoder.header_table_size怎么用?Python Encoder.header_table_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hpack.hpack.Encoder
的用法示例。
在下文中一共展示了Encoder.header_table_size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_resizing_header_table_sends_multiple_updates
# 需要导入模块: from hpack.hpack import Encoder [as 别名]
# 或者: from hpack.hpack.Encoder import header_table_size [as 别名]
def test_resizing_header_table_sends_multiple_updates(self):
e = Encoder()
e.header_table_size = 40
e.header_table_size = 100
e.header_table_size = 40
header_set = [(':method', 'GET')]
out = e.encode(header_set, huffman=True)
assert out == b'\x3F\x09\x3F\x45\x3F\x09\x82'
示例2: test_resizing_header_table_to_same_size_ignored
# 需要导入模块: from hpack.hpack import Encoder [as 别名]
# 或者: from hpack.hpack.Encoder import header_table_size [as 别名]
def test_resizing_header_table_to_same_size_ignored(self):
e = Encoder()
# These size changes should be ignored
e.header_table_size = 4096
e.header_table_size = 4096
e.header_table_size = 4096
# These size changes should be encoded
e.header_table_size = 40
e.header_table_size = 100
e.header_table_size = 40
header_set = [(':method', 'GET')]
out = e.encode(header_set, huffman=True)
assert out == b'\x3F\x09\x3F\x45\x3F\x09\x82'
示例3: test_resizing_header_table
# 需要导入模块: from hpack.hpack import Encoder [as 别名]
# 或者: from hpack.hpack.Encoder import header_table_size [as 别名]
def test_resizing_header_table(self):
# We need to encode a substantial number of headers, to populate the
# header table.
e = Encoder()
header_set = [
(':method', 'GET'),
(':scheme', 'https'),
(':path', '/some/path'),
(':authority', 'www.example.com'),
('custom-key', 'custom-value'),
(
"user-agent",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) "
"Gecko/20100101 Firefox/16.0",
),
(
"accept",
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;"
"q=0.8",
),
('X-Lukasa-Test', '88989'),
]
e.encode(header_set, huffman=True)
# Resize the header table to a size so small that nothing can be in it.
e.header_table_size = 40
assert len(e.header_table.dynamic_entries) == 0
示例4: test_evicting_header_table_objects
# 需要导入模块: from hpack.hpack import Encoder [as 别名]
# 或者: from hpack.hpack.Encoder import header_table_size [as 别名]
def test_evicting_header_table_objects(self):
e = Encoder()
# Set the header table size large enough to include one header.
e.header_table_size = 66
header_set = [('a', 'b'), ('long-custom-header', 'longish value')]
e.encode(header_set)
assert len(e.header_table.dynamic_entries) == 1
示例5: test_indexed_header_field_from_static_table
# 需要导入模块: from hpack.hpack import Encoder [as 别名]
# 或者: from hpack.hpack.Encoder import header_table_size [as 别名]
def test_indexed_header_field_from_static_table(self):
e = Encoder()
e.header_table_size = 0
header_set = {':method': 'GET'}
result = b'\x82'
# Make sure we don't emit an encoding context update.
e.header_table.resized = False
assert e.encode(header_set, huffman=False) == result
assert list(e.header_table.dynamic_entries) == []
示例6: test_setting_table_size_to_the_same_does_nothing
# 需要导入模块: from hpack.hpack import Encoder [as 别名]
# 或者: from hpack.hpack.Encoder import header_table_size [as 别名]
def test_setting_table_size_to_the_same_does_nothing(self):
e = Encoder()
# Set the header table size to the default.
e.header_table_size = 4096
# Now encode a header set. Just a small one, with a well-defined
# output.
header_set = [(':method', 'GET')]
out = e.encode(header_set, huffman=True)
assert out == b'\x82'
示例7: test_resizing_header_table_sends_context_update
# 需要导入模块: from hpack.hpack import Encoder [as 别名]
# 或者: from hpack.hpack.Encoder import header_table_size [as 别名]
def test_resizing_header_table_sends_context_update(self):
e = Encoder()
# Resize the header table to a size so small that nothing can be in it.
e.header_table_size = 40
# Now, encode a header set. Just a small one, with a well-defined
# output.
header_set = [(':method', 'GET')]
out = e.encode(header_set, huffman=True)
assert out == b'?\t\x82'