Repository navigation
Merged
Conversation
…p sending the rest (#587) A handler that takes a body reader runs at end-of-headers. When it answered before its body ended (a 401, a 413, a redirect), RetireBody unpaced the request stream and FeedRequest dropped and credited every byte that kept arriving, and nothing asked the client to stop: a 64 MiB POST answered with a 413 its handler never read still uploaded all 64 MiB. RFC 9114 4.1 lets a server that does not need the rest of a request abort reading it, with H3_NO_ERROR, and has the client keep sending when it does not. #582 did this for ioxide.http2 and ioxide.nghttp3. Once the response is handed over, ioxide.http3 now stops the request's read side with QuicConnection.StopReading(streamId, H3_NO_ERROR), STOP_SENDING alone, at the points nghttp3 uses: after the Submit of a buffered answer, whether its handler returned, threw or awaited, and after a streamed writer's CompleteAsync or FailAsync. Existing state gates it: nothing for a request whose fin arrived or that this side reset (ReqStream.Finished), one the client reset or whose stream closed (gone from _requests), or a connection that is gone (IsBroken). A streamed handler that fails after its headers is reset through the new Http3Connection.ResetResponse, which marks the request Finished as Refuse does, so no STOP_SENDING follows that reset. A client that refused the answer with its own STOP_SENDING is still asked to stop uploading once its handler returns. No change to src/ioxide or the native shims: StopReading and iq_conn_shutdown_stream_read shipped in #582. Tests: E2E Http3EarlyAnswerTests pins what the stack asks of a recording transport, in order, for each answer path, control and guard. E2E EarlyAnswerTests gains ioxide.http3 copies of the raw-client and HttpClient tests. With the http3 sources at origin/main the claims fail ("got [send, send+fin]", "uploaded 4194304 bytes", "uploaded 67108864 of 67108864 bytes"), and removing each call site or guard on its own fails the test written for it.
This was referenced Nov 14, 2026
# Conflicts: # tests/Ioxide.Tests.E2E/Protocols/EarlyAnswerTests.cs
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #587.
A handler that takes a body reader runs at end-of-headers, before its body has arrived. When it answered first (a 401, a 413, a redirect), ioxide.http3 retired the body:
RetireBodyunpaced the request stream, andFeedRequestdropped and credited every byte that kept arriving. Nothing asked the client to stop, so it uploaded the whole body for nothing: a 64 MiB POST answered with a 413 its handler never read still sent all 64 MiB, and the shim's raw client sent its whole 4 MiB budget. RFC 9114 4.1 lets a server that does not need the rest of the request abort reading the request stream, with H3_NO_ERROR, and says that a client whose request is not aborted SHOULD keep sending it. #582 did this for ioxide.http2 and ioxide.nghttp3; the pure C# stack kept reading.The change. All in
src/protocols/ioxide.http3, mirroring nghttp3'sStopReadingIfAnsweredEarly:StopReadingIfAnsweredEarlycallsQuicConnection.StopReading(streamId, H3_NO_ERROR): STOP_SENDING alone, so the response still goes out whole. It runs where nghttp3's does: after theSubmitof a buffered answer, whether its handler returned, threw or awaited, and after a streamed writer'sCompleteAsyncorFailAsync.ReqStream.Finished), one the client reset or whose stream closed (no longer in_requests), or on a connection that is gone (IsBroken).Http3Connection.ResetResponse, which marks the requestFinishedasRefusedoes, so no STOP_SENDING follows that reset.No change to
src/ioxide(QuicConnection.StopReadingexists since #582) and none to the native shims, so nothing is rebuilt.What a caller notices. A client uploading to a body-reader handler that answers before the body ends now gets STOP_SENDING(H3_NO_ERROR) on the request stream once the answer is handed over, and stops: .NET's
HttpClientstops at 192 KiB of 64 MiB, as it does against nghttp3, and the raw client at 0 bytes. The answer still arrives whole. No public API changes.Tests.
Http3EarlyAnswerTests(E2E, new), on a transport that logs what the stack asks of it on the request stream, in order, with every await inline:stop 0x100after the answer's last send: a buffered answer (send, send+fin, stop 0x100), the 500 of a buffered handler that threw at once (send+fin, stop 0x100), a buffered answer its handler awaited, a streamed answer, the 500 of a streamed handler that failed before its headers, and a client that refused the answer (send, send, stop 0x100);send, send, reset 0x102); a request that arrives with its connection's close gets none.EarlyAnswerTests(E2E), on the wire with a realQuicEngine:HttpClientover h3 (msquic, skipped without it): a streamed and a buffered 413 to a 64 MiB upload arrive whole and the upload stops, under the existing 1 MiB bar. Control: an 8 MiB upload its handler reads to the end is sent whole and answered;StartH3andStartHttp3share one engine setup.Seen failing without the fix, with the new tests in place:
src/protocols/ioxide.http3at origin/main, the six recorded claims fail withexpected [send, send+fin, stop 0x100], got [send, send+fin](got [send+fin]for the buffered 500,got [send, send]for the refused client). The four raw-client claims fail withthe client uploaded 4194304 bytes to a handler that read none of them: nothing asked it to stop(4194304 more bytes after the handler returnedfor the refused client), and bothHttpClientclaims withthe client uploaded 67108864 of 67108864 bytes. Controls and guards pass.HttpClientbuffered. After the immediate 500: its recorded claim. After the awaited answer: its recorded claim and the off-reactor raw test. AfterCompleteAsync: the recorded streamed and refused claims, the raw streamed and refused, and theHttpClientstreamed. AfterFailAsync: the recorded streamed 500.Finished, both controls end instop 0x100, and the failure after headers inreset 0x102, stop 0x100. Without the_requestscheck, the client-reset guard ends instop 0x100; withoutIsBroken, the closing-connection guard does. WithResetResponsenot markingFinished, the failure after headers ends inreset 0x102, stop 0x100.Suites, pinned to CPUs 0-3,6-7,14-31: Unit 263/0/0, E2E 748/0/0 (730 before plus the 18 new; msquic is installed, so the
HttpClienth3 tests ran), Chaos 105/0/0 (its h3 cases run nghttp3, not this stack). The early-answer and recorded tests also passed 15 runs in a row, andH3StopSendingTests3.For review.
CompleteAsync. If its last chunk waits on send capacity, the upload is unpaced and dropped for that wait; while the handler runs the stream is still paced, so only that final flush is exposed. Stopping right afterRetireBody, once the headers are out, would close it, at the cost of parity.ResetResponsemarkingFinishedalso means a fin still queued from before that reset is no longer parsed. It could only have led to a second reset, which ngtcp2 ignores, or, for a truncated last frame, an H3_FRAME_ERROR close over a stream this side had already abandoned.HttpClientpair failed one case withQuicException: ... QUIC_STATUS_INTERNAL_ERRORrather than the upload count. In the run whose server log was kept, the server had logged[ioxide.ngtcp2] recv queue overflow; closing connection.under the unpaced 64 MiB upload. It did not recur in 15 runs with the fix, where the upload stops.