1
0
mirror of https://github.com/square/okhttp.git synced 2025-07-29 17:41:17 +03:00

25 Commits

Author SHA1 Message Date
f745695087 Replace SocketPolicy with a new type, SocketEffect (#8870)
* Replace SocketPolicy with a new type, SocketEffect

SocketPolicy encapsulated two things:
 - a trigger (request start, response body, etc)
 - an effect (close the socket, close the stream, stall, etc.)

It also had some special cases for effects like
failing the TLS handshake.

With this PR there's a new class, SocketEffect, that determines
what to do. It's assigned to one of 5 fields for different
triggers.

# Conflicts:
#	mockwebserver/src/main/kotlin/mockwebserver3/MockWebServer.kt

* apiDump

* Track API change

* Track more API changes

* Spotless

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-06-20 07:46:46 -04:00
570277976d Stop using experimental coroutines APIs (#8867)
They're stable now.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-06-19 00:20:30 -04:00
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
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
e1da8bc50e Dependency bumps (#8611) 2024-12-08 14:59:35 +00:00
d6613810ee Move coroutines extensions to okhttp3.coroutines (#8372)
* Move coroutines extensions to okhttp3.coroutines

This has the side-effect of fixing our packaging of this module.
Previously the okhttp-coroutines.jar contained the code from the
:okhttp artifact, not the :okhttp-coroutines artifact. I suspect
something in one of our build steps is incorrectly using the
package names (only) as a cache key, and it should instead be
using the package contents.

* apiDump
2024-04-17 21:24:38 -04:00
aef791ac36 Don't leak response bodies in executeAsync (#8330)
* Don't leak response bodies in executeAsync

Also make callers opt in to an unstable coroutines API. If the resource
cleanup coroutines API changes, we'll have to change this API.

Remove the OkHttp experimental API. This is a good enough API as far
as OkHttp is concerned.

* Spotless
2024-04-05 07:25:23 -04:00
373822e239 Mechanically tag all new APIs as @ExperimentalOkHttpApi (#8216)
* Mechanically tag all new APIs as @ExperimentalOkHttpApi

In a follow-up PR I intend to remove the annotation on any
API that we're willing to commit to for OkHttp 5.0.0.

In a follow-up PR I'd also like to hide all remaining
APIs from Java langauge callers.

* Opt-in ExperimentalOkHttpApi for Android projects too

---------

Co-authored-by: Benoit Quenaudon <benoit@quenaudon.com>
2024-01-23 09:31:42 -05:00
a16dcecfeb Allow constructor injection of MockWebServer (#8191) 2024-01-14 10:20:09 +00:00
a228fd64cc Reformat with Spotless (#8180)
* Enable spotless

* Run spotlessApply

* Fixup trimMargin

* Re-run spotlessApply
2024-01-07 20:13:22 -05:00
23d67c304f Switch to assertFailsWith (#8177)
* Switch to assertk.fail

* Use assertFailsWith

* More assertFailsWith

* Use more assertFailsWith

* More assertFailsWith

* More assertFailsWith

* Native image dependencies

* Move JUnit dependency

* Don't lock in a specific implementation class

* Missing finally
2024-01-06 00:31:00 -05:00
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
6b7b611308 Remove expect/actuals (#8147)
* Remove expect/actuals from okcurl

* Remove expect/actuals from okhttp-coroutines

* Remove expect/actuals from okhttp

* Remove expect/actuals from okhttp-testing-support

* Fixup build scripts
2023-12-19 07:37:45 -05:00
68105a4832 Removing all JS variants (#8145) 2023-12-18 10:49:23 -05:00
30780c879b Add explicit argument name in use lambda function in README.md (#8097) 2023-11-09 10:47:27 -05:00
95cb15ab4d Disable javadoc (#8025) 2023-09-16 10:38:35 +01:00
3ea6b81e5c Make SocketPolicy a sealed interface (#7610)
* Make SocketPolicy a sealed interface

* Dump APIs
2023-01-02 15:13:13 -05:00
fe15ccda5b Switch to a Builder for mockwebserver3.MockResponse (#7578)
* Switch to a Builder for mockwebserver3.MockResponse

* Migrate lots of tests to MockResponse.Builder

* Improve some code style

* Follow naming conventions in MockResponse.Builder

* Apply side-effects for inTunnel=true

* Update the API
2022-12-28 10:13:49 -05:00
69ae7f3e10 Fix lifecycle for Junit 5 extension. (#7392) 2022-08-16 13:01:55 +03:00
58ee1ce170 Revert downgrade to 1.4 for gradle reasons (#7391)
* Revert "Downgrade to kotlin apiVersion 1.4 (#7267)"
* Revert "Improve runtime compatibility with kotlin 1.5.31 (#7343)"
* Revert "Remove usage of toDuration() (#7329)"
2022-07-25 17:57:09 +01:00
6ad9fb12b6 Downgrade to kotlin apiVersion 1.4 (#7267)
* Test against kotlin 1.4

* Compile down to Kotlin 1.4

* Fix to use the invariant locale for lowercase

* Fix to use the invariant locale for lowercase
2022-06-08 10:44:30 -04:00
79f50e1911 Add a proper Kotlin constructor for Request (#7208)
* Add a proper Kotlin constructor for Request

This turns out to be very useful throughout our test suite.

* Dump updated API

* Fix multipleTags Kotlin conversion
2022-04-04 09:44:43 -04:00
b9267b0ce7 Make Response.body non-null (#7205)
This is a source-incompatible API change. In particular, Response.body(null)
is no longer source-compatible for Kotlin source.

The upside is tremendous: no need for callers to use !! on Response.body
on every single API call. In the rare cases where a Response doesn't have
a body we use a runtime error. This is unlikely to cause problems in
practice; users don't have reason to read the response body on supporting
responses.
2022-04-02 13:17:00 -04:00
ab5cadd7f8 Fix coroutines publishing (#7150) 2022-03-09 21:01:54 +00:00
0d2f2eb346 Coroutines module. (#7142)
Implementation of an extension method which is used directly on JVM, and shadows an implementation
directly in Call on other platforms.
2022-03-06 15:31:31 +00:00