当前位置: 首页>>代码示例>>Python>>正文


Python StreamReader.feed_eof方法代码示例

本文整理汇总了Python中aiohttp.streams.StreamReader.feed_eof方法的典型用法代码示例。如果您正苦于以下问题:Python StreamReader.feed_eof方法的具体用法?Python StreamReader.feed_eof怎么用?Python StreamReader.feed_eof使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aiohttp.streams.StreamReader的用法示例。


在下文中一共展示了StreamReader.feed_eof方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mock_stream

# 需要导入模块: from aiohttp.streams import StreamReader [as 别名]
# 或者: from aiohttp.streams.StreamReader import feed_eof [as 别名]
def mock_stream(data):
    """Mock a stream with data."""
    protocol = mock.Mock(_reading_paused=False)
    stream = StreamReader(protocol)
    stream.feed_data(data)
    stream.feed_eof()
    return stream
开发者ID:keatontaylor,项目名称:home-assistant,代码行数:9,代码来源:aiohttp.py

示例2: test_cannot_clone_after_read

# 需要导入模块: from aiohttp.streams import StreamReader [as 别名]
# 或者: from aiohttp.streams.StreamReader import feed_eof [as 别名]
def test_cannot_clone_after_read(loop):
    payload = StreamReader(loop=loop)
    payload.feed_data(b'data')
    payload.feed_eof()
    req = make_mocked_request('GET', '/path', payload=payload)
    yield from req.read()
    with pytest.raises(RuntimeError):
        req.clone()
开发者ID:gleb-chipiga,项目名称:aiohttp,代码行数:10,代码来源:test_web_request.py

示例3: test_cannot_clone_after_read

# 需要导入模块: from aiohttp.streams import StreamReader [as 别名]
# 或者: from aiohttp.streams.StreamReader import feed_eof [as 别名]
async def test_cannot_clone_after_read(loop, protocol):
    payload = StreamReader(protocol, loop=loop)
    payload.feed_data(b'data')
    payload.feed_eof()
    req = make_mocked_request('GET', '/path', payload=payload)
    await req.read()
    with pytest.raises(RuntimeError):
        req.clone()
开发者ID:youpengly,项目名称:aiohttp,代码行数:10,代码来源:test_web_request.py

示例4: test_reading_long_part

# 需要导入模块: from aiohttp.streams import StreamReader [as 别名]
# 或者: from aiohttp.streams.StreamReader import feed_eof [as 别名]
 async def test_reading_long_part(self, newline) -> None:
     size = 2 * stream_reader_default_limit
     protocol = mock.Mock(_reading_paused=False)
     stream = StreamReader(protocol)
     stream.feed_data(b'0' * size + b'%s--:--' % newline)
     stream.feed_eof()
     obj = aiohttp.BodyPartReader(BOUNDARY, {}, stream, _newline=newline)
     data = await obj.read()
     assert len(data) == size
开发者ID:samuelcolvin,项目名称:aiohttp,代码行数:11,代码来源:test_multipart.py

示例5: test_request_with_wrong_content_type_encoding

# 需要导入模块: from aiohttp.streams import StreamReader [as 别名]
# 或者: from aiohttp.streams.StreamReader import feed_eof [as 别名]
async def test_request_with_wrong_content_type_encoding(protocol) -> None:
    payload = StreamReader(protocol)
    payload.feed_data(b'{}')
    payload.feed_eof()
    headers = {'Content-Type': 'text/html; charset=test'}
    req = make_mocked_request('POST', '/', payload=payload, headers=headers)

    with pytest.raises(HTTPUnsupportedMediaType) as err:
        await req.text()
    assert err.value.status_code == 415
开发者ID:KeepSafe,项目名称:aiohttp,代码行数:12,代码来源:test_web_request.py

示例6: test_make_too_big_request_limit_None

# 需要导入模块: from aiohttp.streams import StreamReader [as 别名]
# 或者: from aiohttp.streams.StreamReader import feed_eof [as 别名]
def test_make_too_big_request_limit_None(loop):
    payload = StreamReader(loop=loop)
    large_file = 1024 ** 2 * b'x'
    too_large_file = large_file + b'x'
    payload.feed_data(too_large_file)
    payload.feed_eof()
    max_size = None
    req = make_mocked_request('POST', '/', payload=payload,
                              client_max_size=max_size)
    txt = yield from req.read()
    assert len(txt) == 1024**2 + 1
开发者ID:gleb-chipiga,项目名称:aiohttp,代码行数:13,代码来源:test_web_request.py

示例7: test_make_too_big_request

# 需要导入模块: from aiohttp.streams import StreamReader [as 别名]
# 或者: from aiohttp.streams.StreamReader import feed_eof [as 别名]
def test_make_too_big_request(loop):
    payload = StreamReader(loop=loop)
    large_file = 1024 ** 2 * b'x'
    too_large_file = large_file + b'x'
    payload.feed_data(too_large_file)
    payload.feed_eof()
    req = make_mocked_request('POST', '/', payload=payload)
    with pytest.raises(HTTPRequestEntityTooLarge) as err:
        yield from req.read()

    assert err.value.status_code == 413
开发者ID:gleb-chipiga,项目名称:aiohttp,代码行数:13,代码来源:test_web_request.py

示例8: test_make_too_big_request_adjust_limit

# 需要导入模块: from aiohttp.streams import StreamReader [as 别名]
# 或者: from aiohttp.streams.StreamReader import feed_eof [as 别名]
async def test_make_too_big_request_adjust_limit(loop, protocol):
    payload = StreamReader(protocol, loop=loop)
    large_file = 1024 ** 2 * b'x'
    too_large_file = large_file + b'x'
    payload.feed_data(too_large_file)
    payload.feed_eof()
    max_size = 1024**2 + 2
    req = make_mocked_request('POST', '/', payload=payload,
                              client_max_size=max_size)
    txt = await req.read()
    assert len(txt) == 1024**2 + 1
开发者ID:youpengly,项目名称:aiohttp,代码行数:13,代码来源:test_web_request.py

示例9: test_make_too_big_request

# 需要导入模块: from aiohttp.streams import StreamReader [as 别名]
# 或者: from aiohttp.streams.StreamReader import feed_eof [as 别名]
async def test_make_too_big_request(protocol) -> None:
    payload = StreamReader(protocol)
    large_file = 1024 ** 2 * b'x'
    too_large_file = large_file + b'x'
    payload.feed_data(too_large_file)
    payload.feed_eof()
    req = make_mocked_request('POST', '/', payload=payload)
    with pytest.raises(HTTPRequestEntityTooLarge) as err:
        await req.read()

    assert err.value.status_code == 413
开发者ID:KeepSafe,项目名称:aiohttp,代码行数:13,代码来源:test_web_request.py

示例10: test_multipart_formdata

# 需要导入模块: from aiohttp.streams import StreamReader [as 别名]
# 或者: from aiohttp.streams.StreamReader import feed_eof [as 别名]
def test_multipart_formdata(loop):
    payload = StreamReader(loop=loop)
    payload.feed_data(b"""-----------------------------326931944431359\r
Content-Disposition: form-data; name="a"\r
\r
b\r
-----------------------------326931944431359\r
Content-Disposition: form-data; name="c"\r
\r
d\r
-----------------------------326931944431359--\r\n""")
    content_type = "multipart/form-data; boundary="\
                   "---------------------------326931944431359"
    payload.feed_eof()
    req = make_mocked_request('POST', '/',
                              headers={'CONTENT-TYPE': content_type},
                              payload=payload)
    result = yield from req.post()
    assert dict(result) == {'a': 'b', 'c': 'd'}
开发者ID:gleb-chipiga,项目名称:aiohttp,代码行数:21,代码来源:test_web_request.py

示例11: aiohttp_payload

# 需要导入模块: from aiohttp.streams import StreamReader [as 别名]
# 或者: from aiohttp.streams.StreamReader import feed_eof [as 别名]
def aiohttp_payload(data, encoding="utf8"):
    payload = RequestEncodingMixin._encode_params(data).encode(encoding)
    stream = StreamReader()
    stream.feed_data(payload)
    stream.feed_eof()
    return stream
开发者ID:Tygs,项目名称:tygs,代码行数:8,代码来源:test_utils.py


注:本文中的aiohttp.streams.StreamReader.feed_eof方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。