本文整理汇总了Python中hyperframe.frame.DataFrame.stream_id方法的典型用法代码示例。如果您正苦于以下问题:Python DataFrame.stream_id方法的具体用法?Python DataFrame.stream_id怎么用?Python DataFrame.stream_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hyperframe.frame.DataFrame
的用法示例。
在下文中一共展示了DataFrame.stream_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: socket_handler
# 需要导入模块: from hyperframe.frame import DataFrame [as 别名]
# 或者: from hyperframe.frame.DataFrame import stream_id [as 别名]
def socket_handler(listener):
sock = listener.accept()[0]
e = Encoder()
# We get two messages for the connection open and then a HEADERS
# frame.
receive_preamble(sock)
sock.recv(65535)
# Now, send the headers for the response.
f = build_headers_frame(
[(':status', '200'), ('content-length', '14')],
e
)
f.stream_id = 1
sock.send(f.serialize())
# Also send a data frame.
f = DataFrame(1)
f.data = b'have some data'
sock.send(f.serialize())
# Now, send a headers frame again, containing trailing headers.
f = build_headers_frame([
('trialing', 'no'),
('trailing', 'sure')], e)
f.flags.add('END_STREAM')
f.stream_id = 1
sock.send(f.serialize())
# Wait for the message from the main thread.
recv_event.set()
sock.close()