Upgrade OkHttp from 4.12.0 to 5.4.0#2140
Draft
ramsessanchez wants to merge 1 commit into
Draft
Conversation
- Bump okhttp version in gradle/libs.versions.toml (covers okhttp, logging-interceptor and mockwebserver via the shared version ref). - RedirectHandler: replace removed okhttp3.internal.http.StatusLine constants (HTTP_PERM_REDIRECT/HTTP_TEMP_REDIRECT) with local 308/307 constants, as that internal class is no longer exposed in OkHttp 5. - OkHttpRequestAdapterTest: OkHttp 5 Response.Builder.body is non-null, so drop .body(null) calls. Split the stream no-content test: 204/304 still return null; 200-203 with an empty body now yield a non-null empty stream (matching real OkHttp behavior, production code unchanged). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0b74528e-656e-4569-bb55-b833bbf51344
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.
Overview
Upgrades the OkHttp dependency from 4.12.0 to 5.4.0 for the
components/http/okHttpmodule.Changes
gradle/libs.versions.toml— bumpokhttpto5.4.0. The sharedversion.refcoversokhttp,logging-interceptor, andmockwebserver. The legacycom.squareup.okhttp3:mockwebserverartifact still ships in 5.x, so no package/artifact rename is needed.RedirectHandler.java—okhttp3.internal.http.StatusLineno longer exposesHTTP_PERM_REDIRECT/HTTP_TEMP_REDIRECTin OkHttp 5. Replaced the removed internal imports with local308/307constants. This is the only production-source break.OkHttpRequestAdapterTest.java— OkHttp 5 makesResponse.Builder.bodynon-null, so.body(null)now throwsNullPointerException. Removed those calls. Because a built success response now always carries a non-null (empty) body, the stream no-content test was split:sendStreamReturnsNullOnNoContent— 204/304 still returnnull(viashouldReturnNull).sendStreamReturnsEmptyStreamOnEmptyBody— 200-203 with an empty body yield a non-null empty stream, matching real OkHttp network behavior.Notes
null-body path was only reachable via synthetic mocks; real network responses always carry a non-null body. Production code is unchanged apart from the redirect constants.okhttp3.*core packages are unchanged (no rename to anokhttppackage).Testing
./gradlew :components:http:okHttp:test— 108 tests pass../gradlew :components:bundle:test— pass (bundles okHttp).serialization:json(writesSampleObjectValueWithUntypedProperties) is pre-existing onmainand independent of this change.