OkHttp has lots of constants defined from before it was a
Kotlin library, and I'd rather the library be self-consistent
than consistent with Kotlin idioms.
As a bonus we get to remain consistent with Java idioms.
I'd love a Kotlin mechanism to use @JvmField and @JvmName
at the same time, but I can't figure out how.
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
* Update org.bouncycastle to v1.79
* Handle UnsupportedOperationException – if the underlying provider does not implement the operation
* Handle BC requirements on the key manager
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Yuri Schimke <yuri@schimke.ee>
* 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>
* Prepare to enable Spotless
I'm not super keen on any of these changes, but I am very
keen on having automatic formatting.
* Don't actually enable Spotless yet
* 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
* 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)
We were seeing crashes in Deflater.deflate with a root cause
of closing the deflater while it was in use.
The underlying problem is that web socket streams were closed
when the web socket was canceled, but not by the thread that
owned those streams.
This moves stream cleanup to always run on the owning thread:
- writer cleanup happens on the task queue
- reader cleanup happens after loopReader
This also introduces a new function, Streams.cancel() so a
failed writer can break an active reader, and vise-versa.
Previously we were using close() to do this job.
There's a lot of test changes but it's mostly in adding
the TaskFaker facet to RealWebSocketTest. The test now
runs with a fake clock, with the deterministic benefits
that brings.
See also: https://github.com/square/okhttp/issues/6719
Just hard-coding 'localhost' is simpler and avoids problems where
the host machine's IP address has additional DNS registrations.
Closes: https://github.com/square/okhttp/issues/7603
* Public API for duplex streams in MockWebServer
I'm not 100% on the name 'Stream' for the source+sink pair. It's
tempting to use 'Socket', though I think that's an implementation name
and this is an abstraction that uses a different implementation.
I've chosen Stream specifically 'cause it's the word used in the
HTTP/2 spec. My biggest gripe with it is that it's bidirectional
in the HTTP/2 spec, but Java InputStream and OutputStream are not
bidirectional.
* Dump APIs for streams
* Don't include a Content-Length header for chunked bodies
* Convert MockWebServerTest to Kotlin (#7596)
* Rename .java to .kt
* Convert Java to Kotlin
* Null isn't special for last-write wins
* Attempt to make NonCompletingRequestBody less flaky
* Create MockResponseBody
We'd previously only ever used Buffer to model the type
of the MockResponse body. This has proven inadequate, particularly
for features like duplex responses.
Most of the complexity in this PR is changing how throttling
and disconnect-during-body work when we don't necessarily have
a Buffer for the response body.
This is a first step, more capability to follow.
* Update API
* We flush fewer times now
* Attempt to make a test less flaky
* Try harder to make the test less flaky
* 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
* Implement CONNECT tunnels for HTTP/2 prior knowledge
Closes: https://github.com/square/okhttp/issues/7289
* Update the API spec for MockWebServer
* It is okay for HTTP/2 prior knowledge to send data early
Tests were failing due to an overly-pessimistic 'too much buffering'
exception. I moved the detector to where it's actually needed.
* Change how HTTP 1xx responses work in MockWebServer
Previously this was a SocketPolicy. With this change each
response may carry 0 or more informational responses which
are transmitted before the ultimate response.
* Add a test for multiple 1xx responses
* Update API
This is the only behavior change in the PR. The rest is converting
a test from Java to Kotlin (so it can see this internal member) and
getting a TaskRunner instance into the ExchangeFinder, hopefully
useful for implementing Happy Eyeballs.
Also fix up some formatting problems.
Also migrate some tests that use these Util functions from Java to Kotlin.
If we're going to make OkHttp multiplatform, our tests need to be Kotlin
so we can run them on all supported platforms.