feat: supports setting multiple hosts#2486
Conversation
|
Well, the investigation revealed that httptools changed its behavior in 0.6.3. pip install --upgrade httptools==0.6.3import httptools
REQUEST_AFTER_CONNECTION_CLOSE = b"\r\n".join(
[
b"GET / HTTP/1.1",
b"Host: example.org",
b"Connection: close",
b"",
b"",
b"GET / HTTP/1.1",
b"Host: example.org",
b"",
b"",
]
)
parser = httptools.HttpRequestParser("a")
# Adding this line works fine.
# parser.set_dangerous_leniencies(lenient_data_after_close=True)
print(parser.feed_data(REQUEST_AFTER_CONNECTION_CLOSE))output: print(parser.feed_data(REQUEST_AFTER_CONNECTION_CLOSE))
File "httptools/parser/parser.pyx", line 259, in httptools.parser.parser.HttpParser.feed_data
httptools.parser.errors.HttpParserError: Data after `Connection: close` |
|
Is it a problem on uvicorn or on httptools? |
REQUEST_AFTER_CONNECTION_CLOSE = b"\r\n".join(
[
b"GET / HTTP/1.1",
b"Host: example.org",
b"Connection: close",
b"",
b"",
b"GET / HTTP/1.1",
b"Host: example.org",
b"",
b"",
]
)If such a message exists in a real environment, it's a problem with uvicorn. |
|
I don't understand. Is it because of a security issue that was fixed? |
|
Here are the details of this commit: It looks like the error was passed to the caller, maybe it hadn't been before. I'm not a cython expert. |
|
Oh, I see, now using a more standardized and strict parsing method. That's why the above message, when processed, reported an error. After the connection is closed, no messages should be sent after it. |
So uvicorn should not send anything to the parser after, right? |
|
I don't know, I'd have to read some resources before answering that. |
|
We'll take the next step when we figure it out. |
This problem requires multiple ports, and this PR was originally designed with multiple hosts, so if we want to solve these two problems, then I suggest adding Similar to https://github.com/pgjones/hypercorn/blob/main/src/hypercorn/__main__.py#L45, But our bind only supports host:port, and uds and fd are still separate. Avoid the burden of complicated analysis. |
|
Let's go with #2818. Thanks for this and sorry the delay. |



Summary
On the realization of this discussion
#1529
Checklist