本文整理汇总了Python中hyper.http20.stream.Stream.send_data方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.send_data方法的具体用法?Python Stream.send_data怎么用?Python Stream.send_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hyper.http20.stream.Stream
的用法示例。
在下文中一共展示了Stream.send_data方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bytestrings_can_be_sent
# 需要导入模块: from hyper.http20.stream import Stream [as 别名]
# 或者: from hyper.http20.stream.Stream import send_data [as 别名]
def test_bytestrings_can_be_sent(self):
def data_callback(frame):
assert isinstance(frame, DataFrame)
assert frame.data == b'Hi there!'
assert frame.flags == set(['END_STREAM'])
s = Stream(1, data_callback, None, NullEncoder, None)
s.state = STATE_OPEN
s.send_data(b'Hi there!', True)
assert s.state == STATE_HALF_CLOSED_LOCAL
assert s._out_flow_control_window == 65535 - len(b'Hi there!')
示例2: test_file_objects_can_be_sent
# 需要导入模块: from hyper.http20.stream import Stream [as 别名]
# 或者: from hyper.http20.stream.Stream import send_data [as 别名]
def test_file_objects_can_be_sent(self):
def data_callback(frame):
assert isinstance(frame, DataFrame)
assert frame.data == b"Hi there!"
assert frame.flags == set(["END_STREAM"])
s = Stream(1, data_callback, None, None, NullEncoder, None, None)
s.state = STATE_OPEN
s.send_data(BytesIO(b"Hi there!"), True)
assert s.state == STATE_HALF_CLOSED_LOCAL
assert s._out_flow_control_window == 65535 - len(b"Hi there!")
示例3: test_long_bytestrings_are_split
# 需要导入模块: from hyper.http20.stream import Stream [as 别名]
# 或者: from hyper.http20.stream.Stream import send_data [as 别名]
def test_long_bytestrings_are_split(self):
frame_count = [0]
recent_frame = [None]
def data_callback(frame):
assert isinstance(frame, DataFrame)
assert len(frame.data) <= MAX_CHUNK
frame_count[0] += 1
recent_frame[0] = frame
data = b'test' * (MAX_CHUNK + 1)
s = Stream(1, data_callback, None, NullEncoder, None)
s.state = STATE_OPEN
s.send_data(data, True)
assert s.state == STATE_HALF_CLOSED_LOCAL
assert recent_frame[0].flags == set(['END_STREAM'])
assert frame_count[0] == 5
assert s._out_flow_control_window == 65535 - len(data)
示例4: test_large_file_objects_are_broken_into_chunks
# 需要导入模块: from hyper.http20.stream import Stream [as 别名]
# 或者: from hyper.http20.stream.Stream import send_data [as 别名]
def test_large_file_objects_are_broken_into_chunks(self):
frame_count = [0]
recent_frame = [None]
def data_callback(frame):
assert isinstance(frame, DataFrame)
assert len(frame.data) <= MAX_CHUNK
frame_count[0] += 1
recent_frame[0] = frame
data = b"test" * (MAX_CHUNK + 1)
s = Stream(1, data_callback, None, None, NullEncoder, None, None)
s.state = STATE_OPEN
s.send_data(BytesIO(data), True)
assert s.state == STATE_HALF_CLOSED_LOCAL
assert recent_frame[0].flags == set(["END_STREAM"])
assert frame_count[0] == 5
assert s._out_flow_control_window == 65535 - len(data)