Repository navigation
Send headers of later requests after 100 Continue - #2399
Merged
hyperxpro merged 1 commit intoNov 21, 2026
Merged
Conversation
A 100 Continue sets headersAlreadyWrittenOnContinue on the NettyResponseFuture, so that writeRequest sends the deferred body without the headers, which went out before. Nothing reset the flag, so every later HTTP/1.1 attempt on the same future was sent without its headers too: a redirect, a 401 or 407 retry, a retry after the connection closed, and a ResponseFilter or IOExceptionFilter replay. A request without a body or with an in-memory body is a single message, so nothing at all was written and the request timed out. Other bodies were written on their own, and the HTTP/1.1 encoder rejected them, for example with "unexpected message type: BodyFileRegion". Until 664a50b in 2014, writeRequest reset the flag each time it read it. The flag is now cleared in setNettyRequest, like tunnelEstablished. Every request sent on an existing future goes through it. The deferred body is written by calling writeRequest again for the same request, without a new one, so it still skips the headers. Clearing the flag where it is read, as before 2014, would not be enough: a 100 also sets it when nothing was deferred, for example for an in-memory body, which HTTP/1.1 sends with the headers. Nothing reads the flag then until the next request, which would skip its headers. HTTP/2 does not read the flag. Claude Code on behalf of Matthias Kurz Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hyperxpro
approved these changes
Nov 21, 2026
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.
Summary
NettyResponseFuturewas sent without its headers: a redirect, a 401 or 407 retry, a retry after the connection closed, and aResponseFilterorIOExceptionFilterreplay.String, aByteBuf, form parameters) is a single message, so nothing reached the server and the request waited for its timeout. Any other body was written without a request line, and Netty's encoder rejected it, for example withEncoderException: unexpected message type: BodyFileRegion.Continue100InterceptorsetsheadersAlreadyWrittenOnContinueso thatwriteRequestsends the deferred body without the headers, which already went out. Nothing reset the flag. Until 664a50b (January 2014, first released in 2.0.0-alpha1),writeRequestreset it each time it read it (getAndSetWriteHeaders(true)).Change
NettyResponseFuture.setNettyRequestclears the flag, as it already re-armstunnelEstablished. Every request sent on an existing future goes through it, fromNettyRequestSender.newNettyRequestAndResponseFuture. The deferred body is written by a secondwriteRequestcall for the same request, without a new one, so it still goes out without the headers.writeRequest, as before 2014, would not be enough. A 100 also sets it when nothing was deferred. That is the case for an in-memory body, which HTTP/1.1 sends with the headers even withExpect: 100-continue. Since fix(netty): fail fast when InputStream body cannot be reset #2312, nowriteRequestfollows such a 100, so the flag would stay set until the next request, and that request would skip its headers.RedirectBodyTest: after a 100, a 307 keeps the method, the headers and the body, with a byte array and with aByteArrayBodyGenerator; a 303 reaches the target as a GET; a multipart body survives a 307. AResponseFilterrecords the statuses, and each test checks that a 100 came before the redirect.RedirectBodyTesthandler now sends the 100 itself with Jetty'sHttpChannel.continue100(0). Jetty skips it when the content came with the headers, which is what an in-memory body does. WithoutExpect: 100-continuethe call does nothing, and the existing tests of the class pass unchanged.Expect100ContinueTest: a Basic auth retry after a 100, and aResponseFilterreplay after a 100 and a 503, both with a file body. The server reads the body, which sends the 100, then answers 401 or 503.Notes
Expect: 100-continueheader, although RFC 9110 section 10.1.1 says a client must not send it without content.Expect: 100-continue, asdontWriteBodyBecauseExpectContinueis only set when the future is created. RFC 9110 allows that. The target in the redirect tests answers it with another 100, which does not defer anything.AI disclosure
Claude Code on behalf of Matthias Kurz. The commit includes
Co-Authored-ByperAGENTS.md.Test plan
mainand pass with this PR. Onmain, the byte array 307 and the 303 time out, as nothing reaches the target. The generator 307 fails withunexpected message type: AdvancedLeakAwareByteBuf, the multipart 307 withunexpected message type: BodyFileRegion, and the 401 retry and the filter replay withunexpected message type: DefaultFileRegion. The other 51 tests of the two classes pass on both.writeRequestwriting the headers even after a 100, the existingExpect100Continue,authorizedNonPreemptiveRealmWorksWithExpectContinueanddeferredInputStream307KeepsBodyfail, and so do the new tests with a deferred body. The skip for the deferred body is still needed, and tests cover it.IOExceptionFilterreplay after that close. Both fail onmainwith anEncoderExceptionand pass with this PR.RedirectBodyTest,Expect100ContinueTest,Continue100InterceptorTest,MultipartBasicAuthTest,Http2ConformanceRegressionTest,RetryRequestTest,FilterTest,CrossHostReplayTest,BasicAuthTest,DigestAuthTest,NtlmTestandProxyTest: 319 tests, 0 failures, 2 skipped (@DisabledinAuthTimeoutTest).RedirectBodyTest,Expect100ContinueTest,Continue100InterceptorTestandMultipartBasicAuthTest: 63 tests, 0 failures, on JDK 11, 17, 21 and 25../mvnw -B -ntp -Dgpg.skip=true clean verifyon JDK 11: 2,214 tests, 0 failures, 0 errors, 22 skipped; Revapi passed. Docker was not running, so 11 of the skipped tests are the Testcontainers proxy tests, which skip themselves. No test-skipping flags were used.