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

81 Commits

Author SHA1 Message Date
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
81cfb68ac0 Fewer strings in EventListener asserts (#9118)
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-07 14:15:56 -04:00
Yuri Schimke
bc5ad233f1 Bump robolectric to 4.16 (#9044)
* Bump robolectric

* test with 36

* avoid requiring JDK 21 for Robolectric tests
2025-08-30 17:25:39 +01:00
Benoît Quenaudon
0e0352920b Move the Android test README under the androidTest directory (#9031)
And opt-in to compile without errors
2025-08-22 09:12:58 +01:00
Benoît Quenaudon
929a41c01c Print URLs in HttpLoggingInterceptor when the call fails (#9030) 2025-08-21 15:27:04 +01:00
Yuri Schimke
67c1b8e419 Split android OkHttpClient tests. (#8991)
* Split android OkHttpClient tests.

current tests were using a single client then
testing real network (facebook, ...) and localhost insecure.

Split so we get clearer failures.
2025-08-02 15:12:28 +01:00
Yuri Schimke
3004abe400 okhttp3.Gzip (#8988)
* okhttp3.Gzip

Top level object for consistency.

* reformat and apis
2025-08-01 06:04:22 +00:00
Yuri Schimke
971101cacc Add reusable CompressionInterceptor (#8967)
* Add reusable CompressionInterceptor.kt

Refactor Brotli and Zstd to use this, but also
allow trivial configuration of zstd,br,gzip.
2025-07-29 20:01:04 +00:00
Yuri Schimke
07fe953b40 Add Android OkHttp.initialize(Context) (#8965)
* Add OkHttp.initialiseApplicationContext

A fallback for apps Disabling the AndroidX Startup Initialiser.
2025-07-28 08:33:49 +01:00
Yuri Schimke
50f1be974d Add test demonstrating topPrivateDomain on Robolectric (#8954)
* Add test demonstrating topPrivateDomain on Robolectric
* Handle non robo case
2025-07-22 21:03:31 +01:00
Jesse Wilson
5f3ec584f7 Switch to @StartStop for JUnit 5 tests (#8863)
* New @StartStop extension for JUnit 5

This is a new take on our JUnit 5 extension. Rather than creating and managing
the MockWebServer instance in the extension, we let the user create it and all
the extension does is manage the lifecycle.

Note that this annotation doesn't require any external configuration - it doesn't
need a system-property to opt-into 'automatic' extensions, and it doesn't require
a class-level extension either.

* apiDump

* Switch to @StartStop for JUnit 5 tests

* Fixup visibility

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-06-18 08:28:21 -04: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
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
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
0e7ec0bc1c Fix some missing copyright statements (#8789) 2025-05-22 10:39:30 -04:00
renovate[bot]
a51cfbf841 Update dependency com.diffplug.spotless:spotless-plugin-gradle to v7 (#8702)
* Update dependency com.diffplug.spotless:spotless-plugin-gradle to v7

* Reformat

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
2025-03-19 15:25:20 -04:00
Yuri Schimke
9c653c7b0a Add a StrictMode noteSlowCall for SSL init (#8339)
Add strict mode checks on slow calls
2025-01-05 13:15:05 +00:00
Yuri Schimke
dd5a002d44 Use Assets or Resources based on platform. (#8636)
* Use Assets and Resources based on platform.

Assets uncompressed on Android. Assuming that the AAR file will compress.

Use Resources, compressed on JVM.
2024-12-31 16:50:53 +02:00
Yuri Schimke
1786dd70e7 Merge okhttp-android into okhttp (#8635)
* Merge okhttp-android into okhttp.

Since :okhttp is kmp, it isn't required to be separate. And also the okhttp-android/jvm artifact naming conflicts with it.
2024-12-31 01:28:56 +02:00
Yuri Schimke
5163d93806 Spotless bump (#8205)
* Update dependency com.diffplug.spotless:spotless-plugin-gradle to v6.24.0
* Spotless bump

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-20 10:30:28 +00:00
Yuri Schimke
a16dcecfeb Allow constructor injection of MockWebServer (#8191) 2024-01-14 10:20:09 +00:00
Jesse Wilson
a228fd64cc Reformat with Spotless (#8180)
* Enable spotless

* Run spotlessApply

* Fixup trimMargin

* Re-run spotlessApply
2024-01-07 20:13:22 -05:00
Jesse Wilson
c056530682 Switch back to the kotlin JVM plugin (#8149)
* Switch back to the kotlin JVM plugin

This does a ton of file moves from jvmMain to main, and jvmTest to test.

* Don't use AnimalSniffer on okcurl

* Use assertk more (#8150)
2023-12-20 18:27:07 -05:00
Yuri Schimke
2bed25879f Testing with ALPN Override (#8081) 2023-12-04 06:48:05 +00:00
Yuri Schimke
c309709dbd AGP 8 (#7918) 2023-07-09 12:08:42 +01:00
Yuri Schimke
fa2de5413d Fix android test (#7862) 2023-05-27 14:58:52 +01:00
TangHuaiZhe
d7c3cedd67 Refine doc and comments about android test (#7694) 2023-02-14 10:26:50 +02:00
Yuri Schimke
223682e5e8 Leave default SNI on API 24+ (#7526) 2022-12-31 11:49:02 +10:00
Yuri Schimke
37c1001453 Fix android tests (#7464) 2022-09-24 17:28:22 +01:00
Yuri Schimke
68c36fd5b6 Fix android tests (#7374) 2022-07-16 12:36:06 +01:00
Yuri Schimke
d9b90e1b2c Fix a failing android test and cleanup (#7135) 2022-03-01 07:23:28 +00:00
Yuri Schimke
91f45ce409 Fix android test (#7018) 2022-01-22 12:05:32 +00:00
Yuri Schimke
c1a6dec505 Allow Custom SSLSocketFactory without ALPN support (#6862)
* Allow Custom SSLSocketFactory without ALPN support

* Allow Custom SSLSocketFactory without ALPN support

* Revert reformatting

* Reuse delegate classes
2021-11-23 20:29:18 -05:00
Yuri Schimke
083315a473 Launcher for quick tests (#6437) 2020-11-21 13:28:45 +00:00
Yuri Schimke
ff959f8fd5 Android Additional Tests (#6420) 2020-11-15 06:42:22 +00:00
Yuri Schimke
daac9be139 Fix Android tests post junit 5 (#6408) 2020-11-14 07:12:48 +00:00
Yuri Schimke
6342f2a9c8 Regression Test Module (#6412) 2020-11-13 07:09:56 +00:00
Adrian Cole
c7054e3448 Lints android-test (#6288) 2020-10-01 14:36:35 +08:00
Yuri Schimke
d1490698a3 Make the Android tests pass on <= 23 2020-05-19 18:41:09 +01:00
Yuri Schimke
67f77be6b0 Fix for insecureHost on Android (#6063) 2020-05-18 20:23:00 +01:00
Yuri Schimke
198900de0b Fix isAndroid check (#6055)
Fix for OkHttp platform issues in AndroidStudio (e.g. when running as a plugin)

square/retrofit#3389
2020-05-16 09:09:46 +01:00
Yuri Schimke
80bee1afdd Confirm android logging disabled (#6008) 2020-05-02 09:12:41 -04:00
Yuri Schimke
93ac4fa3b9 Android Cache Test (#6010) 2020-05-01 18:47:29 +01:00
Yuri Schimke
5c10006e0a Centralise logging behind JUL (#6005)
Use JUL, but wire up to the Android Log.

Use `adb shell setprop log.tag.okhttp.Http2 DEBUG` to enable logging for known levels.
2020-04-30 19:04:19 +01:00
Yuri Schimke
27c78a7a47 Fix for android 2020-04-25 10:16:52 +01:00
Yuri Schimke
27454cdec7 Test which TrustManager method called on Android 2020-04-18 10:08:30 +01:00
Yuri Schimke
474b13f86b Workaround bouncycastle random issue (#5942)
* Workaround bouncycastle random issue

* Cleanup
2020-04-12 18:46:48 -04:00
Yuri Schimke
86b7ba5f2a Enable BouncyCastle on Android and add some testing (#5936) 2020-04-11 17:35:27 +01:00
Yuri Schimke
27dbedca9d Migrate to AndroidX for tests 2020-04-09 08:29:13 +01:00