* 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>
* 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>
* 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
* 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
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.
EventSource.cancel() did nothing if it was created by EventSources.processResponse.
All EventSources would continue to process buffered events rather than
breaking out sooner.
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.
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.
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.
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