Handle HTTP/1.1 half-closed connections gracefully.#641
Handle HTTP/1.1 half-closed connections gracefully.#641lovelydinosaur merged 13 commits intomasterfrom
Conversation
…nse is still sent correctly.
|
Test case failure is...
Looks like this block... httpcore/httpcore/_async/http11.py Lines 133 to 135 in 6a97dad Needs an (No, I don't fully understand the generator clean-up stuff here.) |
|
Very weird. I presume this is the https://docs.python.org/3/library/contextlib.html#contextlib.aclosing
This is only available in Python 3.10+ though? You can We're not the only ones :) python/cpython#88684 (comment) |
|
Related: #657 (?) |
I copied the test from this pr and see this error as well. Perhaps it's might be something else. Will try to dig into it |
| with Trace("send_request_body", logger, request, kwargs) as trace: | ||
| self._send_request_body(**kwargs) | ||
| except WriteError: | ||
| # If we get a write error while we're writing the request, |
There was a problem hiding this comment.
What happens if server just closes the request, but don't answer (I saw it in some proxies)? Read will fail, so we will have partially-closed connection?
There was a problem hiding this comment.
The connection is closed and the client raises an exception...
httpcore.RemoteProtocolError("Server disconnected without sending a response.")I've added a test case to demonstrate this.
…iting and does not send a response
|
Ah... Should have added to |
We're experiencing timeout errors in various integrations, but it does not look like we ever send the request to OS2mo/Keycloak/etc. This MR bumps httpx to bump httpcore to 0.18.0 to include this fix: encode/httpcore#641. If we're lucky, that's it. Otherwise, we are probably waiting for this to be merged: encode/httpcore#802.
We're experiencing timeout errors in various integrations, but it does not look like we ever send the request to OS2mo/Keycloak/etc. This MR bumps httpx to a patched version which in turn depends on patched version of httpcore which includes encode/httpcore#802, which I suspect is our issue. Another related issue has also been fixed (encode/httpcore#641), and is already included in httpcore 0.18.0.
Handle cases like HTTP 413, where the request write fails part way through sending, but a properly formed HTTP error response is then sent.
Closes #723
Originally prompted via encode/httpx#2503