8000 Add httptools failing test for long url by euri10 · Pull Request #925 · encode/uvicorn · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add httptools failing test for long url #925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions tests/protocols/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
]
)

LONG_PATH_REQUEST_TEMPLATE = b"\r\n".join(
[b"GET /%s HTTP/1.1", b"Host: example.org", b"", b""]
)


class MockTransport:
def __init__(self, sockname=None, peername=None, sslcontext=False):
Expand Down Expand Up @@ -729,3 +733,30 @@ def test_invalid_http_request(request_line, protocol_cls, caplog, event_loop):
protocol.data_received(request)
assert not protocol.transport.buffer
assert "Invalid HTTP request received." in caplog.messages


@pytest.mark.parametrize(
"path_symbols_num",
[
pytest.param((2 ** 16 - 2), id="(2**16-2)"),
pytest.param((2 ** 16 - 1), id="(2**16-1)"),
],
)
@pytest.mark.parametrize("protocol_cls", HTTP_PROTOCOLS)
def test_get_long_path_request(path_symbols_num, protocol_cls, event_loop):
async def app(scope, receive, send):
nonlocal path_symbols_num
path = scope["path"]
raw_path = scope.get("raw_path", None)
assert "/" + path_symbols_num * "A" == path
assert b"/" + path_symbols_num * b"A" == raw_path

response = Response("Done", media_type="text/plain")
await response(scope, receive, send)

with get_connected_protocol(app, protocol_cls, event_loop) as protocol:
request = LONG_PATH_REQUEST_TEMPLATE % (path_symbols_num * b"A")
protocol.data_received(request)
protocol.loop.run_one()

assert b"Done" in protocol.transport.buffer
0