Skip to content

Commit 2aea835

Browse files
vvanglroKludex
andauthored
fix(http): enable httptools lenient data (#2488)
Co-authored-by: Marcelo Trylesinski <[email protected]>
1 parent fe39100 commit 2aea835

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dependencies = [
3939
[project.optional-dependencies]
4040
standard = [
4141
"colorama>=0.4;sys_platform == 'win32'",
42-
"httptools>=0.5.0",
42+
"httptools>=0.6.3",
4343
"python-dotenv>=0.13",
4444
"PyYAML>=5.1",
4545
"uvloop>=0.14.0,!=0.15.0,!=0.15.1; sys_platform != 'win32' and (sys_platform != 'cygwin' and platform_python_implementation != 'PyPy')",

uvicorn/protocols/http/httptools_impl.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ def __init__(
5858
self.access_logger = logging.getLogger("uvicorn.access")
5959
self.access_log = self.access_logger.hasHandlers()
6060
self.parser = httptools.HttpRequestParser(self)
61+
62+
try:
63+
# Enable dangerous leniencies to allow server to a response on the first request from a pipelined request.
64+
self.parser.set_dangerous_leniencies(lenient_data_after_close=True)
65+
except AttributeError: # pragma: no cover
66+
# httptools < 0.6.3
67+
pass
68+
6169
self.ws_protocol_class = config.ws_protocol_class
6270
self.root_path = config.root_path
6371
self.limit_concurrency = config.limit_concurrency

0 commit comments

Comments
 (0)