Compare commits
10 Commits
feat-2394-
...
fix-2388-s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a84b6cfdb | ||
|
|
2750f0f82a | ||
|
|
0f5de2ef2c | ||
|
|
aef131af90 | ||
|
|
6e40292974 | ||
|
|
db92c1fedd | ||
|
|
bbffdcbd68 | ||
|
|
768d0e09b5 | ||
|
|
9d04f24298 | ||
|
|
6f18c82879 |
@@ -30,7 +30,6 @@ from types import SimpleNamespace
|
||||
from urllib.parse import parse_qs, parse_qsl, unquote, urlunparse
|
||||
|
||||
from httptools import parse_url # type: ignore
|
||||
from httptools.parser.errors import HttpParserInvalidURLError # type: ignore
|
||||
|
||||
from sanic.compat import CancelledErrors, Header
|
||||
from sanic.constants import DEFAULT_HTTP_CONTENT_TYPE
|
||||
@@ -131,12 +130,7 @@ class Request:
|
||||
|
||||
self.raw_url = url_bytes
|
||||
# TODO: Content-Encoding detection
|
||||
try:
|
||||
self._parsed_url = parse_url(url_bytes)
|
||||
except HttpParserInvalidURLError as InvalidURLError:
|
||||
raise InvalidUsage(
|
||||
"URL is invalid or malformed"
|
||||
) from InvalidURLError
|
||||
self._parsed_url = parse_url(url_bytes)
|
||||
self._id: Optional[Union[uuid.UUID, str, int]] = None
|
||||
self._name: Optional[str] = None
|
||||
self.app = app
|
||||
|
||||
@@ -21,25 +21,3 @@ def test_bad_request_response(app):
|
||||
app.run(host="127.0.0.1", port=42101, debug=False)
|
||||
assert lines[0] == b"HTTP/1.1 400 Bad Request\r\n"
|
||||
assert b"Bad Request" in lines[-2]
|
||||
|
||||
|
||||
def test_malformed_uri_bad_request(app):
|
||||
lines = []
|
||||
|
||||
app.get("/")(lambda x: ...)
|
||||
|
||||
@app.listener("after_server_start")
|
||||
async def _request(sanic, loop):
|
||||
connect = asyncio.open_connection("127.0.0.1", 42101)
|
||||
reader, writer = await connect
|
||||
writer.write(b"GET /\r\nHost: ---.com\r\n\r\n")
|
||||
while True:
|
||||
line = await reader.readline()
|
||||
if not line:
|
||||
break
|
||||
lines.append(line)
|
||||
app.stop()
|
||||
|
||||
app.run(host="127.0.0.1", port=42101, debug=False)
|
||||
assert lines[0] == b"HTTP/1.1 400 Bad Request\r\n"
|
||||
assert b"Bad Request" in lines[-2]
|
||||
Reference in New Issue
Block a user