Repository navigation
Conversation
Three interceptors send a copy of the request they handle, made with
toBuilder(): ConnectSuccessInterceptor for the first request in a new
tunnel, and the 401 and 407 interceptors for the retry with
credentials. toBuilder() encodes the URI again, so a request built
with URL encoding disabled was sent encoded: /a|b?q={x} went out as
/a%7Cb?q=%7Bx%7D. That hit the https, wss or ws request that opens a
tunnel through an HTTP or HTTPS proxy, every retry after a 401, and
every retry after a 407 to an http request. A request that takes a
pooled tunnel is not copied.
Copy a DefaultRequest with URL encoding disabled instead, as AsyncHttpClient#2393
does for a Range header, through one package-private builder that the
three interceptors share. Another Request implementation still goes
through its own toBuilder(), which copies it as before. The copies are
still copies, so nothing else about them changes.
Claude Code on behalf of Matthias Kurz
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Motivation: Three interceptors send a copy of the request they handle, made with
Request.toBuilder():ConnectSuccessInterceptor, for the first request in a new tunnel, once the proxy accepts the CONNECT;Unauthorized401InterceptorandProxyUnauthorized407Interceptor, for the retry with credentials.toBuilder()encodes the URI again, so a request built with URL encoding disabled was sent with a different request target:/a|b?q={x}went out as/a%7Cb?q=%7Bx%7D. That hit thehttps,wssorwsrequest that opens a tunnel through an HTTP or HTTPS proxy, every retry after a 401, and every retry after a 407 to anhttprequest. A request that takes a pooled tunnel is not copied. #2384 and #2393 fixed the sametoBuilder()effect for stored cookies and theRangeheader, and #2412 does for a request that changes proxy.Modification: A
DefaultRequestis copied with the raw URI encoder, through one package-privateRequestBuilderBasesubclass that the three interceptors share, asResumableAsyncHandlerdoes since #2393. Subclasses and otherRequestimplementations still go throughtoBuilder(), as they may override what it copies.CallerCookies.refresh, which gets the retry's builder, now takes anyRequestBuilderBase.Result: For a
DefaultRequest, the origin, or the proxy for anhttprequest, receives the request target as the request was built: on the first request in a new tunnel, and on each retry with credentials. AnotherRequestimplementation keeps the copy its owntoBuilder()makes. A request built with URL encoding enabled is sent as before.Tests:
HttpsProxyTest:httpsrequest through an HTTP proxy, built with URL encoding disabled and enabled, to an origin that records the request target as it arrived;DefaultRequestsubclass, whose owntoBuilder()still makes the tunnel's request.AuthRetryRawUriTest: Basic and Digest retries after a 401 and after a 407, plus a guard with URL encoding enabled. The server accepts any credentials, so these check the request target only.Reverting any one of the five copies fails exactly its own test, and so does matching the class with
instanceof.Not changed: this doesn't cover every internal copy.
replayOfConnectRetry(Keep CONNECT and proxy login out of established tunnels #2410) also copies withtoBuilder(), when a filter replays a CONNECT retry. It is left for the open question on Keep CONNECT and proxy login out of established tunnels #2410.toBuilder(), but sends the URI fromLocation, not the one it copied.AI disclosure
Claude Code on behalf of Matthias Kurz. The commit includes
Co-Authored-ByperAGENTS.md.Test plan
All on JDK 11. Docker was not running, so the skipped tests include the Testcontainers proxy tests.
./mvnw -B -ntp -Dgpg.skip=true clean verify: 2,499 tests, 0 failures, 22 skipped; Revapi passed against 3.0.15.AuthRetryRawUriTestandHttpsProxyTest5 times: 20 of 20 each time.instanceofinstead of the exact class fails the subclass test.