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

531 Commits

Author SHA1 Message Date
Jesse Wilson
2bc0b0f25d Use SHOUTY_CASE for static constants (#8802)
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>
2025-05-27 10:51:25 -04:00
Yuri Schimke
e7b86fed23 Fix test with latest JDKs (#8765)
* Fix test with latest JDKs

Change in https://bugs.openjdk.org/browse/JDK-8335135

> HttpInputStream does not throw IOException when response is truncated

* Update mockwebserver/src/test/java/mockwebserver3/MockWebServerTest.kt

Co-authored-by: Jake Wharton <github@jakewharton.com>

---------

Co-authored-by: Jake Wharton <github@jakewharton.com>
2025-05-10 21:11:56 +01:00
Yuri Schimke
f2640e0b08 Create a friends configuration to use internals. (#8651)
* Create a friends configuration to use internals.

From https://www.liutikas.net/2025/01/12/Kotlin-Library-Friends.html we should avoid using

@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

So instead lets just be friends.
2025-05-10 12:15:14 +01:00
木葉 Scarlet
33854ec0d6 Empty constant of Headers, RequestBody, ResponseBody (#8720)
* `Empty` constant of Headers, RequestBody, ResponseBody

removed informal internal constants
2025-04-05 12:39:37 +01: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
renovate[bot]
8cc665f95a Update org.bouncycastle to v1.79 (#8441)
* 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>
2024-12-28 15:22:24 +00:00
Jesse Wilson
23dbc1e643 Use the name webSocketCloseTimeout (#8316)
The name closeTimeout might be mistaken as a regular HTTP
option.
2024-03-31 13:16:15 -04:00
Arlo O'Keeffe
66ae138b17 allow configuring web socket close timeout (#8189) 2024-03-31 11:45: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
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
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
0e312d7804 Prepare to enable Spotless (#8179)
* 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
2024-01-07 11:05:34 -05:00
Jesse Wilson
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
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
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
Jesse Wilson
c9f62b501a Advertise 4.12.0 in docs 2023-12-17 10:34:10 -05:00
julian-goettingen
0fea18494c Update README.md (#8132)
Doc-change that would have avoided my mistake that I made a bug-report about.
2023-12-07 09:33:25 +00:00
Jesse Wilson
cb1674309f Fix a concurrency problem with web socket cleanup (#8121)
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
2023-12-02 11:51:52 -05:00
Yuri Schimke
95cb15ab4d Disable javadoc (#8025) 2023-09-16 10:38:35 +01:00
Yuri Schimke
248b0e6318 Update Release version (#7792) 2023-05-01 11:27:57 +01:00
Yuri Schimke
f408411ff9 Avoid exposing internal methods (#7734) 2023-04-23 08:05:59 +01:00
Jesse Wilson
4d1f8add89 Confirm we send SNI server names on the JDK9 Platform (#7597)
This introduces a new API in MockWebServer's RecordedRequest to
capture the inbound server names.

Co-authored-by: Yuri Schimke <yuri@schimke.ee>
2023-01-04 07:59:45 +10:00
Jesse Wilson
ebb6e92d93 Use classes where appropriate in SocketPolicy (#7622)
* Use classes where appropriate in SocketPolicy

* Track API changes
2023-01-03 11:37:42 -05:00
Jesse Wilson
3ea6b81e5c Make SocketPolicy a sealed interface (#7610)
* Make SocketPolicy a sealed interface

* Dump APIs
2023-01-02 15:13:13 -05:00
Jesse Wilson
847b5af240 Avoid InetAddress.getCanonicalHostName(). (#7607)
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
2023-01-02 09:04:37 -05:00
Jesse Wilson
a55e0090c9 Get rid of MwsDuplexAccess (#7608)
Its unnecessary now that we have a public API type for streams
2023-01-02 13:17:16 +10:00
Jesse Wilson
fe6db78647 Get more TLS stuff passing on BouncyCastle (#7602)
There's something up with ECDSA on BouncyCastle, and rather
than figuring it out I've just switched to RSA signatures
with that provider.
2022-12-31 20:39:55 -05:00
Jesse Wilson
34bb12533b Public API for duplex streams in MockWebServer (#7595)
* 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
2022-12-31 13:24:52 -05:00
Jesse Wilson
c30d3ce7b7 Create MockResponseBody (#7593)
* 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
2022-12-31 14:47:55 +10:00
Jesse Wilson
d8159d499b Run all the tests in CI (#7592)
When we split jvmTest and jsTest, we lost the tests of JVM-only
modules.
2022-12-30 19:09:50 -05: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
f27a291975 Add tests for multiple routes (#7563) 2022-12-24 10:26:45 +10: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
Jesse Wilson
e9a3ad3d94 4.10.0 is out 2022-06-12 10:09:53 -04:00
Jesse Wilson
afc7fa3700 Delete the unused tunnelProxy argument (#7317)
* Delete the unused tunnelProxy argument

* Update API spec
2022-06-09 13:14:05 -04:00
Jesse Wilson
fd6452596c Implement CONNECT tunnels for HTTP/2 prior knowledge (#7314)
* 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.
2022-06-08 13:55:16 -04: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
0218c50da5 Change how tunnels are configured with MockWebServer (#7313)
This is the MockWebServer side of changing how HTTP/2 prior knowledge
works with proxies.

https://github.com/square/okhttp/issues/7289
2022-06-08 09:51:55 -04:00
Jesse Wilson
513a5435c0 Change how HTTP 1xx responses work in MockWebServer (#7169)
* 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
2022-03-19 20:17:50 -07:00
Jesse Wilson
9e039e9412 Don't interpret headers as trailers after a 100 response (#7168)
This only occurs when the response body is empty.

Closes: https://github.com/square/okhttp/issues/7167
2022-03-19 06:52:45 -07:00
Jesse Wilson
3e16ec28fe Adopt Kotlin's binary compatibility validator (#7112) 2022-02-26 14:17:33 -05:00
Yuri Schimke
362f53546d Adopt Version Catalog and Updates plugin (#7075) 2022-02-15 23:38:32 +00:00
Goooler
f5758b7f26 Enable Gradle's type-safe project accessors (#7069) 2022-02-08 20:01:28 +00:00
Yuri Schimke
bb8ecb9595 Test to verify half close behaviour (#7058) 2022-02-08 08:04:42 +00:00
Jesse Wilson
14218871df Change OkHttpClient.routeDatabase to be internal (#7017)
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.
2022-01-16 13:05:24 -05:00
Jesse Wilson
c30d9ad14b Convert more tests to Kotlin (#6980) 2022-01-05 00:20:25 -05:00
Jesse Wilson
ab055862a4 Promote some util functions to commonMain (#6979)
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.
2022-01-03 16:41:53 -05:00
Yuri Schimke
54d22eb7b4 Confirm proxied request url is correct. (#6932) 2021-12-01 07:21:50 -05:00
Goooler
8debc78b00 Simplify gradle kts (#6931) 2021-11-27 12:31:27 +00:00