Compare commits

..

10 Commits

Author SHA1 Message Date
Adam Hopkins
0a84b6cfdb Merge branch 'main' into fix-2388-strtobool 2022-02-02 20:44:19 +02:00
Stephen Sadowski
2750f0f82a lint: fixed linting (again) across all files 2022-02-01 15:15:55 -06:00
Stephen Sadowski
0f5de2ef2c fix: replace strtobool inside setup.py; including from sanic.utils is a no-go 2022-02-01 15:07:12 -06:00
Stephen Sadowski
aef131af90 fix: linting errors 2022-02-01 14:33:34 -06:00
Stephen Sadowski
6e40292974 test: add strtobool validation test for deprecation replacement 2022-02-01 14:15:35 -06:00
Stephen Sadowski
db92c1fedd fix: update sanic.utils.str_to_bool to match deprecated strtobool, changed setup.py to use sanic.utils.str_to_bool 2022-02-01 14:11:52 -06:00
Stephen Sadowski
bbffdcbd68 fix: added message when ValueError is raised for strtobool replacement 2022-01-24 06:52:36 -06:00
Stephen Sadowski
768d0e09b5 fix: removed distutils dependency in setup.py per PEP 632 2022-01-23 19:57:30 -06:00
Stephen Sadowski
9d04f24298 fix: E501 line too long. 2022-01-23 18:48:49 -06:00
Stephen Sadowski
6f18c82879 fix: replace distutils.strtobool() with locally implemented version per PEP 632 2022-01-23 09:43:14 -06:00
2 changed files with 1 additions and 29 deletions

View File

@@ -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

View File

@@ -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]