1
0
mirror of https://github.com/square/okhttp.git synced 2026-01-12 10:23:16 +03:00
Commit Graph

5898 Commits

Author SHA1 Message Date
Jesse Wilson
dfd1dffb3c Decompose the request line into individual properties (#8860)
* Decompose the request line into individual properties

Replace the 'path' property with the URL's encodedPath
property.

Rename the 'requestUrl' property to 'url'.

* Spotless

* Fix up DnsOverHttpsTest

* Fix some test failures
2025-06-16 20:47:36 -04:00
Jesse Wilson
33b093a86c Stabilize the JUnit 4 API (#8857)
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-06-16 18:36:18 -04:00
Jesse Wilson
db836de300 Fix a liveness bug in MockWebServer (#8858)
* Fix a liveness bug in MockWebServer

It was possible to configure delays that would be honored
after MockWebServer was shut down. With this fix any
delay will be abandoned once the server is closed.

* Update mockwebserver/src/main/kotlin/mockwebserver3/internal/SleepNanos.kt

Co-authored-by: Jake Wharton <jw@squareup.com>

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
2025-06-16 11:00:51 -04:00
Jesse Wilson
b4181838a3 Change RecordedRequest.body to a ByteString (#8856)
* Change RecordedRequest.body to a ByteString

Immutable is good.

* apiDump

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-06-14 14:13:40 -04:00
Jesse Wilson
6b134f769a Enable explicit API mode in mockwebserver3. (#8854)
Also remove @ExperimentalOkHttpApi in a few places.

Also rename 'shutdown' to 'close' in MockWebServer
and Dispatcher.

Also rename QueueDispatcher.enqueueResponse() to
QueueDispatcher.enqueue.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-06-14 12:09:26 -04:00
Jesse Wilson
817b7a89d4 Change MockWebServer to use Okio's new Socket interface (#8853)
* Change MockWebServer to use Okio's new Socket interface

This replaces the Stream interface introduced in a recent
alpha release.

* apiDump

* Only buffer once

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-06-13 19:09:36 -06:00
renovate[bot]
f792e219ed Update com.squareup.okio to v3.13.0 (#8852)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-13 11:15:05 -04:00
Jake Wharton
69f6861a4d Migrate to Sonatype Central Portal (#8772) 2025-06-12 16:04:31 -04:00
renovate[bot]
52ebd02385 Update dependency de.mannodermaus.gradle.plugins:android-junit5 to v1.13.0.0 (#8851)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-11 15:31:51 -04:00
renovate[bot]
c759f7af4d Update de.mannodermaus.junit5 to v1.8.0 (#8850)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-11 15:31:21 -04:00
renovate[bot]
eeb0848564 Update dependency org.eclipse.platform:org.eclipse.osgi to v3.23.100 (#8848)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-10 07:05:29 -04:00
renovate[bot]
88ce0c0470 Update dependency com.google.devtools.ksp:symbol-processing-gradle-plugin to v2.1.21-2.0.2 (#8847)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-09 23:17:38 -04:00
renovate[bot]
867dfe0a09 Update junit5 monorepo (#8846)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-07 12:33:20 +01:00
Yuri Schimke
24b8d2942c Add a test and fix for non-robolectric android test. (#8844)
If Robolectric not active, then unit tests for Android will fail annoyingly.
2025-06-07 11:09:33 +01:00
renovate[bot]
3e60223b09 Update dependency gradle to v8.14.2 (#8843)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-05 13:22:27 -04:00
every-time
5a341a3cef fix some dates in changelog (#8842) 2025-06-05 12:55:55 -04:00
Jesse Wilson
71a759f77e Move gzip() from RequestBody to Request.Builder (#8838)
On Request.Builder the one function can add the header
and apply compression. Otherwise the caller needs to
keep those calls in sync.

One severe drawback of this approach is the calls to
Request.Builder are now ordered. If you call gzip()
before you call post(), it'll crash. Worse, if you
call post() and then gzip() and then post() again
with a different body, it'll silently not compress
the new body. I don't love this drawback but I think
the mitigations aren't worth the effort.
2025-06-04 13:43:43 -04:00
renovate[bot]
a1863a71f4 Update org.bouncycastle to v1.81 (#8839)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-04 08:25:49 -04:00
Jesse Wilson
5eecd519aa Finalize the new API for MockResponse (#8837)
* Finalize the new API for MockResponse

It's a value object with a bunch of fields, and a builder.

* Tunnel then body

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-06-03 13:10:21 -04:00
Jesse Wilson
85269fb71b Temporarily remove AddressPolicy from the public API (#8836)
I would like to do more work on the API and implementation
before committing to this API, and I want to do that after
we cut 5.0 final.
2025-06-03 13:10:08 -04:00
木葉 Scarlet
7abfffb5d6 fix immutableListOf array (#8816)
* fix immutableListOf array

* singleton optimization

* Update -UtilJvm.kt
2025-06-03 12:18:33 -04:00
Jesse Wilson
cf11b3c696 Promote Path.asRequestBody() (#8835)
It's reasonable and it's tested.
2025-06-02 22:23:54 -04:00
Jesse Wilson
599d038229 Promote TrailersSource to our public API (#8833)
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-06-02 21:28:45 -04:00
Jesse Wilson
6de88ec621 TrailersSource, a new public API for HTTP trailers (#8829)
* TrailersSource, a new public API for HTTP trailers

This doesn't change much.

The new interface replaces a Kotlin lambda that had
similar behavior, though that lambda wasn't specified
as thoroughly.

We now permit calls to Response.trailers() before the
entire response body is consumed. But when such calls are
made the response body is discarded first. This could be
a bit of a surprise to users, especially users who do an
additional layer of buffering over their ResponseBody
because it could yield latent failures.

But I think it's better behavior overall, especially since
it's possible data binding layers might not consume the
entire response body in all cases. For example, a JSON
library might not read to the very end of the response
if it has received a terminating '}' byte.

The riskiest part of this change is when ResponseBodySource
self-reports as complete. Previously it would self-report
as complete when it returned as many bytes as promised
in the Content-Length. With this change it will now only
report itself complete when it receives a definitive EOF
on the stream, signaled by a -1 byte count on a read. This
is because only when the EOF is received can we be sure
that the trailers are received, and we must not unhook
the Exchange from the Call until that happens. The previous
behavior could make Call.cancel() no-op even if we were
blocked waiting on trailers.

* apiDump

* Attempt to get more tests passing

* Don't wait for stream EOF to release the stream

One of our tests caught a situation where we were waiting
for the caller to read the EOF when we didn't need to.

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-06-02 10:42:05 -04:00
renovate[bot]
a3a0472440 Update dependency com.puppycrawl.tools:checkstyle to v10.25.0 (#8832)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-31 13:33:43 -04:00
Jesse Wilson
80c71d2129 Temporarily remove ConnectionListener from the public API (#8831)
I'd like to update the API to improve observability into things
like ConnecitonPool, RoutePlanner, ConnectPlan, and ReusePlan.
And also into HTTP/2 internals like flow-control.

As-is this is more coupled to Call lifecycles and is somewhat
duplicative with ConnectionPool.

We'll do that work and make it a new public API, but we won't
have it in the public API at all for the 5.0 release.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-05-30 17:28:20 -04:00
Jesse Wilson
f141d4df96 Promote FileDescriptor.toRequestBody to a stable API (#8830) 2025-05-30 17:27:36 -04:00
renovate[bot]
6f256ead5b Update junit5 monorepo (#8828)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-30 08:03:45 -04:00
renovate[bot]
f826c47515 Update testcontainers-java monorepo to v1.21.1 (#8825)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-29 18:46:29 -04:00
Jesse Wilson
8720aa82ce Temporarily stash the AsyncDns stuff (#8823)
It isn't used anywhere yet. I want to get back to this soon
but I don't want to release 5.0.0 final with any incomplete
APIs.

https://github.com/square/okhttp/issues/8318
2025-05-29 16:09:10 -04:00
Jesse Wilson
c0cabbab8b Run the loom tests on JDK 24 (#8820)
* Run the loom tests on JDK 24

I recently broke support for Loom on earlier JDKs

* Install JDK24

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-05-29 13:52:11 -04:00
Jesse Wilson
c758cee605 Prepare next development version. 2025-05-29 12:55:57 -04:00
Jesse Wilson
e6daf2e89f Prepare for release 5.0.0-alpha.16. parent-5.0.0-alpha.16 2025-05-29 12:55:43 -04:00
Jesse Wilson
54cbf3174a Fix test execution on Robolectric (#8822)
* Fix test execution on Robolectric

We had a regression in 5.0.0-alpha.15 that broke test execution
on Robolectric. Now that works again.

Closes: https://github.com/square/okhttp/issues/8821

* Spotless

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-05-29 12:52:38 -04:00
Jesse Wilson
0e17a67f10 Prepare next development version. 2025-05-29 08:28:45 -04:00
Jesse Wilson
a2b9c0cf24 Prepare for release . parent- 2025-05-29 08:27:38 -04:00
renovate[bot]
b70841f56a Update dependency com.android.tools.build:gradle to v8.10.1 (#8819)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-28 20:21:15 -04:00
Jesse Wilson
90d3a6b7c1 Be consistent about syntax to lock, wait, and notify (#8818)
The Dispatcher class is an outlier here as it cannot implement
the Lockable interface without that leaking into its public API.
We do without in that case.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-05-28 19:28:25 -04:00
Jesse Wilson
acd192ade5 Change the locking mechanism to 'synchronized' (#8817)
* Change the locking mechanism to 'synchronized'

We migrated to ReentrantReadWriteLock to better support Loom,
but now we can use synchronized and still support Loom.
This old mechanism may be faster than ReentrantReadWriteLock.

* Update okhttp/src/commonJvmAndroid/kotlin/okhttp3/internal/concurrent/Lockable.kt

Co-authored-by: Yuri Schimke <yuri@schimke.ee>

---------

Co-authored-by: Jesse Wilson <jesse@swank.ca>
Co-authored-by: Yuri Schimke <yuri@schimke.ee>
2025-05-28 13:15:47 -04:00
renovate[bot]
1ae04ad8ba Update dependency com.diffplug.spotless:spotless-plugin-gradle to v7.0.4 (#8814)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-27 22:21:56 -04:00
Jesse Wilson
7e83c84f50 Start using BufferedSource.indexOf() with a toIndex (#8813)
* Upgrade Okio to 3.12.0

* Start using BufferedSource.indexOf() with a toIndex

This avoids the need for the new FixedLengthSource class.

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-05-27 22:11:14 -04:00
Jesse Wilson
82a37936be Upgrade Okio to 3.12.0 (#8812)
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-05-27 22:10:54 -04:00
Jesse Wilson
dbf1047ae1 Stop double-compressing the PublicSuffixDatabase (#8797)
* Stop double-compressing the PublicSuffixDatabase

It's compressed as a .gz file that's also in a .jar file.

Previously the compressed size was 42,502 bytes, and the
total okhttp.jar file was 884,193.

With this change, the total okhttp.jar file is 884,154 bytes.

* PR feedback

* Spotless
2025-05-27 18:00:49 -04:00
Jesse Wilson
cad304afe7 Fix native image tests' build (#8811)
* Fix native image tests' build

They need friendsImplementation to test internal APIs

* Also fix the package name

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-05-27 17:44:11 -04:00
Jesse Wilson
7513e02567 Fix a failing test by adding a FollowUpDecision event (#8809)
* Fix a failing test by adding a FollowUpDecision event

* Fix up the other events list

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-05-27 14:52:42 -04:00
Jesse Wilson
f046fa258a Inline RequestCommon (#8806)
* Inline RequestCommon

This is an artifact of our multiplatform exploration.

* Fixup null tags

* Spotless

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-05-27 14:34:18 -04:00
Jesse Wilson
6f0b54f08e Get the OSGi plugin to work with Kotlin/Multiplatform (#8810)
* Get the OSGi plugin to work with Kotlin/Multiplatform

This introduces a hacky workaround to a BND bug:
https://github.com/bndtools/bnd/issues/6590

* Fix build issues

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-05-27 14:34:03 -04:00
Jesse Wilson
d53f069ee0 Inline ResponseCommon (#8808)
This is an artifact of our multiplatform exploration.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-05-27 11:19:53 -04:00
Jesse Wilson
18632a3227 Inline ChallengeCommon (#8803)
* Inline ChallengeCommon

This is an artifact of our multiplatform exploration.

* Spotless
2025-05-27 11:01:35 -04:00
Jesse Wilson
2f6a27f048 Split EventListener.retryDecision into retryDecision and followUpDecision (#8796)
* Split EventListener.retryDecision into retryDecision and followUpDecision

retryDecision has an exception, and is related to
connectivity failures.

followUpDecision has an intermediate response, and is
related to redirects and auth challenges.

This drops the reason strings, which have 'logging brain'
and I want to push our users towards 'metrics brain'.

* Spotless

* apiDump

* Fix another test

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-05-27 10:58:02 -04:00