1
0
mirror of https://github.com/square/okhttp.git synced 2026-01-14 07:22:20 +03:00

68 Commits

Author SHA1 Message Date
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
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
fb22f4973e Update to official GraalVM tooling (#8613) 2024-12-21 10:56:29 +02:00
Jesse Wilson
212e0e17aa Put EventSources.createFactory into the public API (#8336)
It really needs to be in the public API because the
function it replaces is deprecated.
2024-04-06 00:18:15 -04:00
Jesse Wilson
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
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
eb6c016f6f Stop using AssertJ (#8174)
* Stop using AssertJ

This completes the migration to assertk.

* Fix a missing import

* Fix some type issues
2024-01-04 00:32:07 -05:00
Jesse Wilson
9724956cb4 Convert more tests from Java to Kotlin (#8155) 2023-12-23 10:26:25 +00:00
Jesse Wilson
f131fae164 Change SSE to use the OkHttp public API only (#8141)
* Change SSE to use the OkHttp public API only

Previously we prevented end-users from using their own
implementations of Call.Factory because we casted down
to RealCall in RealEventSource.

With this change we're implementing SSE without depending
on any OkHttp implementation details.

This also introduces a new function in EventSources to
create an EventSource.Factory from a Call.Factory, and
hides the previous implementation that required a concrete
OkHttpClient.

Finally this fixes SSE to publish the same EventListener
events as regular HTTP calls.

* apiDump
2023-12-17 09:39:59 -05:00
Yuri Schimke
505f06dd68 Retry flaky test (#7632) 2023-01-05 22:00:05 +10:00
Jesse Wilson
3ca2e64744 Clean up some Mockwebserver3 internals (#7582) 2022-12-29 06:27:59 +10:00
Jesse Wilson
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
Yuri Schimke
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
Yuri Schimke
68c36fd5b6 Fix android tests (#7374) 2022-07-16 12:36:06 +01:00
Yuri Schimke
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
Jesse Wilson
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
Jesse Wilson
192f05dace Make EventSource.cancel() fail the call immediately (#6924)
EventSource.cancel() did nothing if it was created by EventSources.processResponse.
All EventSources would continue to process buffered events rather than
breaking out sooner.
2021-11-23 08:14:55 +00:00
Yuri Schimke
4b8880aa29 Android 12 Build Dependency (#6892)
* Android 12 Build Dependency
* Add extension required for android junit5 runner
2021-11-14 09:35:27 +00:00
Jim Hurne
bcfdb4f2eb Fix EventSources.processResponse to not throw UninitializedPropertyAccessException (#6887) 2021-10-22 17:51:49 +01:00
Goooler
b668b75f11 Replace deprecated methods (#6776) 2021-07-29 10:08:34 +03: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
4036fa55b7 Update remaining junit4 tests (#6421) 2020-11-14 12:21:04 -05:00
Jesse Wilson
963c768643 Migrate all OkHttpClientTestRule uses to JUnit 5 (#6365) 2020-10-31 18:51:34 -04:00
Yuri Schimke
e2b868c538 Migrate Logging tests to Junit5 (#6356) 2020-10-31 08:10:34 -04:00
Jesse Wilson
334eb00725 Rename okhttp3.internal.sse to okhttp3.sse.internal (#6284)
I think this is slightly neater from an OSGi/JPMS perspective.
2020-10-01 21:46:58 -04:00
Yuri Schimke
a76c40a935 Kotlin 1.4 dependency upgrade and language features (#5947) 2020-09-06 16:36:12 +01:00
Yuri Schimke
5f67bd1e5b Set implicit Accept for EventSource (#6044) 2020-05-13 07:33:03 +01:00
Yuri Schimke
86b7ba5f2a Enable BouncyCastle on Android and add some testing (#5936) 2020-04-11 17:35:27 +01:00
Yuri Schimke
19771365f2 Rename to src/main/kotlin (#5938)
Follows the default path logic for kotlin classes.
2020-04-11 17:15:25 +01:00
Jesse Wilson
3d3b0f6400 Fold together RealCall and Transmitter
These two were 1:1 with each other and there were a few places in the code
where we had both. Putting them into the same class creates a class that
does has a lot of responsibilities, but I believe it's simpler overall than
having two classes.
2020-02-02 15:51:53 -05:00
Jesse Wilson
c1d50e371f Upgrade Okio and some build dependencies
The new ktlint sorts imports which makes this diff large.

The new japicmp ignores 'final' modifier changes in final classes.

We adopt the Google style for checkstyle.xml.

Okio readByteString() now uses segments more aggressively, so we
need to mitigate that to avoid tracking those segments in a test.
2020-01-11 22:24:12 -05:00
Yuri Schimke
0b6c0d25d0 ErrorProne cleanup of two modules (#5640)
* Fix

* Fix 2
2019-12-08 19:49:27 -05:00
Yuri Schimke
16173e2af9 Make Platform.log exception parameter optional (#5482)
Make Platform.log exception parameters optional, and reorders to allow level defaulting to INFO.
2019-09-29 16:59:58 +10:00
Jesse Wilson
9849ab8e3b Create OkHttpClient instances eagerly in tests
We used to do this lazily because OkHttpClient instances were
somewhat heavy: each standalone instance held its own
ExecutorService for the connection pool.

Now that we have TaskRunner each instance is much more
lightweight and the drawbacks of creating instances eagerly
is negligible.
2019-09-28 20:53:12 -04:00
Jesse Wilson
ad5d6b8a7b Make OkHttpClientTestRule more powerful.
I'm hoping to follow this up with a change so that this rule can also do the
uncaught exception handling that we're currently doing elsewhere.

See https://github.com/square/okhttp/issues/4894
2019-06-15 22:08:18 -04:00
Jesse Wilson
53ba4dd9ef Replace MediaType.get(string) with string.toMediaType() (#5132) 2019-05-27 06:38:35 +01:00
Masaru Nomura
7ad4f970ba Idiomatic Kotlin for Response.kt
- define `@get:JvmName(...)` for the following vals in constructor instead of passing `builder: Builder`.
  - `request: Request`
  - `protocol: Protocol`
  - `message: String`
  - `code: Int`
  - `handshake: Handshake?`
  - `headers: Headers`
  - `body: ResponseBody?`
  - `networkResponse: Response?`
  - `cacheResponse: Response?`
  - `priorResponse: Response?`
  - `sentRequestAtMillis: Long`
  - `receivedResponseAtMillis: Long`
  - `exchange: Exchange?`

- add `@Deprecated(...)` to the following functions.
  - `fun request(): Request`
  - `fun protocol(): Protocol`
  - `fun message(): String`
  - `fun code(): Int`
  - `fun handshake(): Handshake?`
  - `fun headers(): Headers`
  - `fun body(): ResponseBody?`
  - `fun networkResponse(): Response?`
  - `fun cacheResponse(): Response?`
  - `fun priorResponse(): Response?`
  - `fun sentRequestAtMillis(): Long`
  - `fun receivedResponseAtMillis(): Long`
  - `fun cacheControl(): CacheControl`

- clean up code where `()`(parentheses) is unnecessarily used.
2019-05-24 16:16:29 -04:00
Jesse Wilson
3552e695c4 Get rid of Internal.kt (#5097)
It's no longer necessary
2019-05-23 05:50:45 +01:00
Jesse Wilson
030dbeae26 Delete unwanted whitespace.
I think the convert-to-Kotlin feature adds these
2019-05-22 21:12:55 -04:00
Jake Wharton
450750c031 Eliminate Util object in favor of top-level functions 2019-05-20 18:13:30 -04:00
Jesse Wilson
110ad6db0a Adopt idiomatic Kotlin in CipherSuite, Cookie, and MediaType 2019-05-13 22:19:43 -04:00
Jesse Wilson
1fe6c3382e Merge pull request #5040 from yschimke/remove_everything_is_non_null
Remove package-info.java
2019-05-12 09:07:52 -04:00
Yuri Schimke
6a4d933847 Convert Internal to Kotlin (#5041)
* Convert Internal to Kotlin

* Fix

* Update Internal.kt

* Update Internal.kt
2019-05-12 09:07:20 -04:00
Yuri Schimke
076593222d Remove package-info.java 2019-05-12 10:10:38 +01:00
Jesse Wilson
74a9c28ba0 Convert RealEventSource.java to .kt (#4910)
* Rename RealEventSource.java to .kt

* Convert RealEventSource.java to .kt
2019-04-14 08:16:06 -04:00
Jesse Wilson
484a5d84a9 Use more idiomatic Kotlin in EventSources and elsewhere 2019-04-07 20:06:07 -04:00
Jesse Wilson
34b1909cc7 Convert okhttp-sse to Kotlin (#4896)
* Rename EventSource.java to .kt

* Convert okhttp-sse to Kotlin
2019-04-07 16:48:44 -04:00
Jesse Wilson
dedc6ecd5b Use more AssertJ features 2019-03-14 17:57:42 -04:00