Commit Graph

6106 Commits

Author SHA1 Message Date
renovate[bot]
09224c5ab1 Update mcr.microsoft.com/devcontainers/java Docker tag to v25 2025-10-16 14:01:51 +00:00
renovate[bot]
935c146b09 Update dependency org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin to v0.11.2 (#9153)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-16 14:55:10 +01:00
renovate[bot]
ed7fcd86bb Update com.squareup.okio to v3.16.2 (#9149)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-14 14:53:00 -04:00
renovate[bot]
5d2fd3145f Update dependency com.puppycrawl.tools:checkstyle to v12.0.1 (#9147)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-11 18:14:27 -04:00
renovate[bot]
3cc91af61e Update de.mannodermaus.junit5 to v1.9.0 (#9145)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-11 16:47:00 +01:00
renovate[bot]
bc81a338b2 Update dependency de.mannodermaus.gradle.plugins:android-junit5 to v1.14.0.0 (#9146)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-11 16:46:41 +01:00
Yuri Schimke
fdbbdbdb50 Resolve local.properties in a VS Code safe way (#9144) 2025-10-11 10:17:37 +01:00
Martin Bonnin
a480881021 Bump Gradle to 9.1.0 (#9114) 2025-10-11 10:02:42 +01:00
Yuri Schimke
43f54705ec Change allowedVersions for junit5 to '<5.14.0' 2025-10-11 09:35:05 +01:00
Yuri Schimke
0c133b9c97 revert some Renovate config (#9141)
* revert some Renovate config

* Fix formatting in renovate.json

* Update allowedVersions for junit5 to <=5.14.0
2025-10-11 09:03:14 +01:00
Yuri Schimke
b0186243f9 Update junit configuration in renovate.json (#9138)
* Update junit configuration in renovate.json

avoid major updates

* Add monorepo and recommended groups to Renovate config

* Remove groupName from junit-framework configuration

Removed groupName for junit-framework monorepo.

* Update Renovate config by removing ignored dependencies

Removed ignored dependencies from Renovate configuration.

* Update Renovate configuration to use junit5
2025-10-11 08:27:29 +01:00
Yuri Schimke
690d1df929 Make tests fail on UnsupportedOperationException (#9135)
* Make tests fail on UnsupportedOperationException

Will fail without the okio fix.

```
09:14:49.703  E  FATAL EXCEPTION: MockWebServer TaskRunner (Ask Gemini)
                 Process: okhttp.android.test.test, PID: 10087
                 java.lang.UnsupportedOperationException
                 	at javax.net.ssl.SSLSocket.shutdownOutput(SSLSocket.java:851)
                 	at okio.internal.DefaultSocket$SocketSink.close(DefaultSocket.kt:95)
                 	at okio.ForwardingSink.close(ForwardingSink.kt:37)
                 	at mockwebserver3.internal.MockWebServerSocket$sink$1.close(MockWebServerSocket.kt:69)
                 	at okio.RealBufferedSink.close(RealBufferedSink.kt:287)
                 	at okhttp3.internal.http2.Http2Writer.close(Http2Writer.kt:331)
                 	at okhttp3.internal.http2.Http2Connection.close$okhttp(Http2Connection.kt:474)
                 	at okhttp3.internal.http2.Http2Connection$ReaderRunnable.invoke(Http2Connection.kt:638)
                 	at okhttp3.internal.http2.Http2Connection$ReaderRunnable.invoke(Http2Connection.kt:619)
                 	at okhttp3.internal.concurrent.TaskQueue$execute$1.runOnce(TaskQueue.kt:112)
                 	at okhttp3.internal.concurrent.TaskRunner$runnable$1.run(TaskRunner.kt:81)
                 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                 	at java.lang.Thread.run(Thread.java:818)
```

* cleanup
2025-10-10 11:26:44 +01:00
Yuri Schimke
d5b3f2c762 Fix SSL Handshake issue affecting MockWebserver on Android 24 (#9129)
* Fix SSL Handshake issue affecting MockWebserver on Android 24

Only called in MWS, but fails on API 24 when called. Adds a single Junit 4 test to run on Android 21-24.

Add a test since Junit 5 wasn't running on older devices.

* fix version number

* reformat

* reformat
2025-10-10 06:19:46 +01:00
Jesse Wilson
29bd9cda98 Fix Okio 3.16.1 link 2025-10-09 19:53:28 -04:00
renovate[bot]
2bc1d55ee6 Update com.squareup.okio to v3.16.1 (#9133)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-09 19:25:26 -04:00
Jesse Wilson
dad534a815 Put 5.2.1 in the changelog 2025-10-09 19:13:15 -04:00
Yuri Schimke
2f3491c0fb Run android tests on API 23 (#9128) 2025-10-09 22:15:26 +01:00
renovate[bot]
ce6c0a03b1 Update dependency com.puppycrawl.tools:checkstyle to v12 (#9127)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-09 16:00:44 -04:00
renovate[bot]
c04ea389ba Update dependency com.squareup.zstd:zstd-kmp-okio to v0.4.0 (#9096)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-09 07:52:46 -04:00
renovate[bot]
6f1a51666e Update dependency org.codehaus.mojo:animal-sniffer-annotations to v1.26 (#9124)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-09 00:46:04 -04:00
Jesse Wilson
0030b10a0b Flatten ConnectionUser (#9122)
There's only one implementation in use, and so I'm
inlining it to call through what it ultimately does.

My motivation is to avoid retaining a reference to an
EventListener anywhere, because that value is going
from immutable to mutable.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-07 23:50:05 -04:00
renovate[bot]
3787f44778 Update dependency com.google.devtools.ksp:symbol-processing-gradle-plugin to v2.2.20-2.0.4 (#9121)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-07 18:22:46 -04:00
Jesse Wilson
b82f7abf0a Tear down AddressPolicy (#9120)
It's currently unused.

I'd like to bring this feature back soon, but using
regular Calls to make it happen rather than having
Connections created without a Call object. That should
avoid some special cases.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-07 17:55:03 -04:00
Jesse Wilson
651d5669dc New function, EventListener.plus() (#9119)
Use this to support multiple EventListeners in the same
call.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-07 17:03:04 -04:00
Jesse Wilson
81cfb68ac0 Fewer strings in EventListener asserts (#9118)
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-07 14:15:56 -04:00
Jesse Wilson
8eca8a834b Prepare next development version. 2025-10-07 11:47:40 -04:00
Jesse Wilson
2a95ed0873 Prepare for release 5.2.0. parent-5.2.0 2025-10-07 11:47:25 -04:00
Jesse Wilson
acfae325f0 Revert "Add minimal HttpLoggingInterceptor support for streaming request and responses. (#8993)" (#9115)
This reverts commit c998c2c57b.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-07 11:15:46 -04:00
Jesse Wilson
d82e8750c4 Put Brotli and Gzip in top-level files (#9116)
This doesn't have any impact on compatibility.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-07 11:15:28 -04:00
Tobias Gesellchen
d4a5be134e Fix RequestBody events on upgraded connections (#8970)
* Add SocketSink{Start,End} events

* Add SocketSource{Start,End} events

* Emit SocketSink/Source events

* Ensure same connection

* Chore

* Chore

* There and back again

* Update okhttp/src/commonJvmAndroid/kotlin/okhttp3/internal/connection/Exchange.kt

* Update okhttp/src/commonJvmAndroid/kotlin/okhttp3/internal/connection/Exchange.kt

---------

Co-authored-by: Jesse Wilson <jesse@swank.ca>
2025-10-07 10:17:39 -04:00
Martin Bonnin
112a19d5e4 Add RequestBody.sha256() (#9109)
* Add RequestBody.sha256()

* * SHA256 -> SHA-256
* Return ByteString, not String

* simplify test

* Move extension function to a regular class method

* Add @Throws(IOException::class)
2025-10-07 10:16:29 -04:00
Jesse Wilson
d41a755c7e Start publishing dispatcher queue events (#9111)
* Start publishing dispatcher queue events

* Update okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-07 10:16:22 -04:00
Jesse Wilson
c06ff312b2 Get Content-Type from the request body (#9113)
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-06 19:46:55 -04:00
Jesse Wilson
fdac86bb90 Make Request.toCurl work more like Chrome's 'copy as cURL' (#9112)
* Make Request.toCurl work more like Chrome's 'copy as cURL'

Changes:
 - single quotes
 - URL first
 - omit the default method

Also change binary detection to use isProbablyUtf8
instead, which is promoted to the main okhttp module.

Also replace the BinaryMode enum with a boolean to
optionally not include the body.

* More aggressive character escaping

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-06 18:47:06 -04:00
Hamza Badar
fa84a6e0d7 feat: add curl() method to Request for generating cURL commands (#8897)
* feat: add curl() method to Request for generating cURL commands

This commit introduces a new `curl()` method in the `Request` class that generates a cURL command equivalent for the HTTP request. This is useful for debugging, logging, and reproducing requests outside of the application.

Key features:
- Includes HTTP method (`-X`), headers (`-H`), and request body (`--data`) if present.
- Handles escaping of special characters in body content.
- Appends the request URL.
- Provides KDoc consistent with the existing codebase.
- Added unit tests for:
  - GET requests with headers.
  - POST requests with complex JSON bodies containing nested objects and arrays.

* feat: add curl() method test cases to RequestTest for generating cURL commands

* update okhttp api

* Use Buffer for request body reading and improve curl generation

- Replace ByteArray-based reads with okio.Buffer for efficiency
- Detect binary data by inspecting bytes instead of relying on Content-Type
- Add BinaryMode options: HEX, OMIT, FILE, STDIN
- Default binary mode is now STDIN (`--data-binary @-`)

* update toCurl method Doc
- use intArrayOf instead of listOf
- update binaryMode param default value
- don't clone buffer twice

---------

Co-authored-by: Yuri Schimke <yuri@schimke.ee>
Co-authored-by: Hamza Badar <hamzabadar@Hamzas-MacBook-Air.local>
2025-10-06 16:53:35 -04:00
Jesse Wilson
e3e996095b Use a single synchronized block in Dispatcher (#9110)
Previously we had synchronized blocks preceding calls
to promoteAndExecute, plus the synchronized blocks in
that function itself.

This is intended to make it easier to publishg the right
events for dispatcherQueueStart and dispatcherQueueEnd
when an enqueued call can skip the queue.

Also note that this should fix some corner-cases around
unnecessary calls to idleCallback when the executor is
already shut down.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-06 14:34:01 -04:00
Jesse Wilson
90079a10a3 Allow HTTP/1.1 Upgrades with empty RequestBody (#9105)
* Allow HTTP/1.1 Upgrades with empty RequestBody

See https://docs.docker.com/reference/api/engine/version/v1.51/#tag/Container/operation/ContainerAttach

* Rewrite the upgrade require() call

This is easier for me to understand.

---------

Co-authored-by: Tobias Gesellchen <tobias@gesellix.de>
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-06 10:05:30 -04:00
Jesse Wilson
e6250bdb2d Introduce events for the dispatcher queue (#9106)
So event listeners can see how long calls are waiting for
resources to become available.

This is the API only. I'll do the implementation in
follow-up.

Also note that I'm going to try my best to implement
this event pair to only fire for calls that actually
spend time in the queue. Calls that are immediately
promoted out of the queue should not get events.
2025-10-06 09:40:20 -04:00
Martin Bonnin
9e58516947 Add KDoc for Request.Builder.query() (#9107) 2025-10-05 08:03:06 +01:00
Yuri Schimke
22786bd3f9 Enable QUERY caching via cacheUrlOverride (#9101)
* Enable QUERY caching via cacheUrlOverride

Reuse tests from https://github.com/square/okhttp/pull/9027

But with minimal support requiring a specific override.

* fix comment
2025-10-03 13:41:45 -04:00
Yuri Schimke
eb2e5a8b54 Fix comments from modules PR (#9102) 2025-10-03 09:35:58 +01:00
Jesse Wilson
185c408c62 Revert "refactor(SSE): move static functions to extensions (#9010)" (#9098)
* Revert "refactor(SSE): move static functions to extensions (#9010)"

This reverts commit 09fb9a448a.

* Remove unnecessary control flow from a test (#9099)

Co-authored-by: Jesse Wilson <jwilson@squareup.com>

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-03 08:51:20 +01:00
Jesse Wilson
7721acd852 Revert "Add QUERY caching support (#9027)" (#9097)
* Revert "Add QUERY caching support (#9027)"

This reverts commit bc269e3d5a.

* Also don't cache QUERY for now

Will bring this back when we use cacheUrlOverride for QUERY

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-03 08:50:58 +01:00
renovate[bot]
fa783c3dda Update gradle/actions action to v5 (#9095)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-01 18:46:11 -04:00
renovate[bot]
3df36fdffa Update dependency com.puppycrawl.tools:checkstyle to v11.1.0 (#9091)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-28 13:13:55 -04:00
renovate[bot]
60680e282d Update dependency org.apache.httpcomponents.client5:httpclient5 to v5.5.1 (#9089)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-27 14:12:07 -04:00
renovate[bot]
7defade315 Update dependency com.gradleup.shadow:shadow-gradle-plugin to v9.2.2 (#9087)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-26 08:06:27 -04:00
renovate[bot]
74ae35cecf Update dependency org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin to v0.11.1 (#9086)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-25 14:45:55 -04:00
renovate[bot]
1585478fc2 Update dependency maven-wrapper to v3.3.4 (#9085)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-25 19:22:49 +01:00
renovate[bot]
1495b28568 Update dependency com.diffplug.spotless:spotless-plugin-gradle to v8 (#9083)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-24 18:04:13 -04:00