1
0
mirror of https://github.com/square/okhttp.git synced 2026-10-24 07:59:29 +03:00

167 Commits

Author SHA1 Message Date
Jesse Wilson
bc8df40582 Release OkHttp 5.5.1 2026-10-22 12:15:31 +08:00
Shayan Khan
75d8f91cfe Throw UnknownHostException on DnsOverHttps HTTP errors (#9698) (#9776) 2026-10-02 23:12:46 -04:00
Jesse Wilson
a94bdf1520 Prepare for release 5.5.0. 2026-08-16 12:08:03 -04:00
Yuri Schimke
ecc3b05adf Use a fixed size for DoH request body (#9687)
* Use a fixed size for DoH request body
* Jesses toRequestBody suggestions
2026-08-16 13:18:00 +01:00
Yuri Schimke
9926082660 Revert "Use a fixed size for DoH request body" (#9686)
This reverts commit 0070c2e7b4.
2026-08-15 19:37:54 +01:00
Yuri Schimke
0070c2e7b4 Use a fixed size for DoH request body 2026-08-15 19:31:56 +01:00
Jesse Wilson
5e0b9d7198 Fold EchAwareDns into AndroidDns (#9645)
* Fold EchAwareDns into AndroidDns

I don't think each DNS feature should be its own DNS class; instead the single
DNS implementation should be configurable.

None of these classes have shipped in a stable release, so there's no risk
of breaking backwards-compatibility.

* Track changes in EchClientTest
2026-08-10 13:16:11 -04:00
Jesse Wilson
d291c023c9 Enable in-memory caching in DnsOverHttps and AndroidDns (#9594)
The default cache size is 1,000, which is effectively unbounded
for mobile apps, which likely call a few dozen API servers, ad
networks, and analytics systems.

I don't expect DnsOverHttps to be deployed in other environments.
If so, it's possible this cache will be problematic, as even
10-second stale results can be problematic for server
environments. I'll put an appropriate warning about this in our
release notes.
2026-07-25 23:18:15 -04:00
Jesse Wilson
23f38965d3 Move DoH public/private host rules into the DnsQuery (#9593)
I had attempted to avoid making StateMachineDnsCall have its own
TaskRunner, instead relying exclusively on the DnsQuery callback
for concurrency. This was more complexity than it was worth, and
it interacted awkwardly with the cache.

Now the DnsOverHttps DnsQuery enforces this invariant, and the
adjacent code is simpler because of it.
2026-07-25 17:53:19 -04:00
Jesse Wilson
1682d9bac8 Rearrange new DNS classes without changing behavior (#9584)
* Rearrange new DNS classes without changing behavior

Transport is now DnsQuery.Factory
CachingTransport is now DnsCache
StateMachineDnsCall.Query is now DnsQuery

This is intended to make it possible to have end-users get a DnsCache
instance without being exposed to the implementation details of our
transports and things.

* Use has-a, not is-a for the MemoryCache

* Update AndroidDns

* Track a test API change

* spotless
2026-07-24 12:36:54 -04:00
Jesse Wilson
8956946b37 More tests for the new DNS cache (#9581)
* More tests for the new DNS cache

* Spotless

* Rename DnsCallStateMachine to StateMachineDnsCall (#9582)

It's no longer necessary to have both the call and the state machine,
the state machine can implement Dns.Call directly.
2026-07-23 16:03:25 -04:00
Jesse Wilson
0f4e198d5f New CachingTransport (#9579)
* Switch to Question as the Transport argument

It makes caching easier.

* New CachingTransport

* spotless

* Switch to ComparableTimeSource

* Switch from computeIfAbsent to putIfAbsent

The former isn't available on API 21.
2026-07-23 11:28:14 -04:00
Jesse Wilson
2ff0781bd6 Update to Okio 3.18, including the new APIs (#9577) 2026-07-22 13:29:57 -04:00
Jesse Wilson
06bd0ef676 Move the DNS call state machine into okhttp (#9576)
* Move the DNS call state machine into okhttp

* Missing annotation
2026-07-22 10:09:24 -04:00
Yuri Schimke
1a3ae1ff29 Move DnsMessage to okhttp core internal (#9571) 2026-07-21 16:47:28 -04:00
Jesse Wilson
d120673e39 Split the state machine out of DnsOverHttps (#9569)
* Split the state machine out of DnsOverHttps

There's a few things that are a bit awkward, but overall it seems
like it'll afford swapping in UDP or Android's resolver.

* Fixup exception text

* Spotless
2026-07-21 13:40:17 -04:00
Jesse Wilson
b2cbae722d Implement Dns.lookup on Dns.newCall for DnsOverHttps (#9568)
* Implement Dns.lookup on Dns.newCall for DnsOverHttps

The lookup path is no longer exercised by OkHttp itself.

This reduces potential drift between the two strategies.

* Spotless

* Update okhttp-dnsoverhttps/src/test/java/okhttp3/dnsoverhttps/DnsOverHttpsTest.kt

Co-authored-by: Yuri Schimke <yuri@schimke.ee>

---------

Co-authored-by: Yuri Schimke <yuri@schimke.ee>
2026-07-21 11:31:14 -04:00
Jesse Wilson
6846f1f679 Rename includeHttps to includeServiceMetadata (#9565)
* Rename includeHttps to includeServiceMetadata

'HTTPS' is way too confusing for DnsOverHttps, because it's about
a DNS record type and not the transport for which records are
retrieved.

* Fix another includeHttps use
2026-07-19 21:59:19 -04:00
Jesse Wilson
25724c1827 Reject malformed messages that have infinite loops (#9562) 2026-07-19 14:21:49 -04:00
Jesse Wilson
6268afe895 Serialize calls to Dns.Callback (#9561)
We had a bug where these calls could be made in parallel. Making
them serial is a bit awkward but doesn't require any locks if we're
clever.
2026-07-19 09:01:41 -04:00
Jesse Wilson
20fcded4b5 Start including ECH data in RouteSelector results (#9557)
* Start including ECH data in RouteSelector results

This changes RouteSelector to use our new async API, when it is
available.

* Extract the execute() function

* Fixup Https results to use targetName

* Fixup some tests

* Use LinkedBlockingQueue instead of CompletableFuture

CompletableFuture isn't available until Android API 24
2026-07-17 19:08:33 -04:00
Jesse Wilson
759a4e5b2d Add ECH service metadata to Route. (#9556)
* Add ECH service metadata to Route.

Also combine DnsOverHttpsServer with FakeDns, so we can serve metadata
anywhere we're testing DNS.

Also move stuff to the 'internal' package in okhttp-dnsoverhttps, so we
can make symbols visible to the main okhttp module's tests.

* Fixup tests

* Test DNS returning zero results
2026-07-17 16:19:48 -04:00
Jesse Wilson
6d0e76d0b9 Define only one DNS interface (#9554) 2026-07-17 11:42:20 -04:00
Jesse Wilson
e14cdaa7a2 DnsOverHttps Fixups: event sequencing, resolvePublicAddresses, IPv6 first (#9553)
* New tests for HTTPS records

* Honor resolvePrivateAddresses and resolvePublicAddresses in DnsOverHttps

* Spotless

* Test canceling after a partial success

* Use a volatile to track whether it's canceled

* Spotless
2026-07-17 09:46:23 -04:00
Jesse Wilson
f542df894f Implement Dns2 on DnsOverHttps (#9550)
* WIP: Implement Dns2 on DnsOverHttps

Obviously this needs more than zero tests.

* Test the new API with the old tests
2026-07-16 09:06:06 -04:00
Jesse Wilson
8bf87e8d2f Change how we test DnsOverHttps (#9549)
* Change how we test DnsOverHttps

Rather than returning opaque hard-coded response bodies, use our
new message encoder so we can test with real value objects.

* Fixup internal API
2026-07-16 07:31:04 -04:00
Jesse Wilson
127cfe2516 Write DNS messages (#9545) 2026-07-14 15:45:52 -04:00
Jesse Wilson
d86233eb45 Decode HTTPS DNS records (#9543)
* Decode HTTPS DNS records

* Spotless

* Fix refactor

* apiDump

* Cut some allocations

* animal sniffer
2026-07-14 12:33:15 -04:00
Jesse Wilson
37b3a953a7 Write our own DNS message reader (#9541)
* Write our own DNS message reader

* Spotless

* Avoid hashCode accelerators

* PR feedback
2026-07-14 09:14:51 -04:00
Jesse Wilson
61423f472d Prepare for release 5.4.0. 2026-06-08 15:34:43 -04:00
Yuri Schimke
c4f96b781a Adopt a full modern gradle build (#9292)
* Introduce build-logic decoupled convention plugins
* Switch to a full modern gradle build
2026-02-03 22:17:59 +00:00
Yuri Schimke
9e9aab7eee Introduce build-logic decoupled convention plugins (#9289)
Use for 1 feature, publishing. And also move current buildSrc logic there.

First step to cleaning up build logic generally.
2026-02-01 16:35:35 +00:00
Yuri Schimke
7f3a220877 Switch to Dokka v2 (#9263)
* Update Dokka to v2

update configuration to use experimental V2 plugin mode and adjust documentation generation scripts.
2026-01-25 12:37:13 +00:00
Jesse Wilson
d1aaf7c6cc Split RecordingEventListener in two (#9180)
The first half is EventListenerAdapter, which mechanically
converts event function calls and emits event objects.

The second half is EventRecorder, which validates that the
right events are published.

This is in preparation for a follow-up where I intend
to dynamically add EventListeners to a Call.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-11-04 14:13:52 -05:00
Jesse Wilson
0960b47ec2 Prepare for release 5.3.0. 2025-10-30 17:39:59 -04:00
Jesse Wilson
dad534a815 Put 5.2.1 in the changelog 2025-10-09 19:13:15 -04:00
Jesse Wilson
81cfb68ac0 Fewer strings in EventListener asserts (#9118)
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-10-07 14:15:56 -04:00
Jesse Wilson
2a95ed0873 Prepare for release 5.2.0. 2025-10-07 11:47:25 -04:00
Yuri Schimke
b7290e4db2 Add multi-release jars to enable Java Modules (#8767)
* Add multi-release jars to enable Java Modules
* Fix android tests
* Avoid running module tests on JDK 8
* Add a jlink run task to demonstrate java modules
2025-09-21 07:22:22 +01:00
Jesse Wilson
d2dd180697 Prepare for release 5.1.0. 2025-07-07 15:32:33 -04:00
Jesse Wilson
1b703d52a9 Prepare for release 5.0.0. 2025-07-03 10:43:08 -04:00
Jesse Wilson
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
Jesse Wilson
dfd1dffb3c Decompose the request line into individual properties (#8860)
* Decompose the request line into individual properties

Replace the 'path' property with the URL's encodedPath
property.

Rename the 'requestUrl' property to 'url'.

* Spotless

* Fix up DnsOverHttpsTest

* Fix some test failures
2025-06-16 20:47:36 -04:00
Jesse Wilson
8720aa82ce Temporarily stash the AsyncDns stuff (#8823)
It isn't used anywhere yet. I want to get back to this soon
but I don't want to release 5.0.0 final with any incomplete
APIs.

https://github.com/square/okhttp/issues/8318
2025-05-29 16:09:10 -04:00
Jesse Wilson
27ddd2c286 Drop the findbugs dependency (#8769)
We don't need it.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
2025-05-13 20:51:50 -04: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
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
Yuri Schimke
61ab31ab1d Simplify the DnsOverHttps logic (#8383)
* Simplify the logic.

Rely on OkHttpClient caching, instead of a cache only request.

* Simplify the logic.

Rely on OkHttpClient caching, instead of a cache only request.
2024-11-18 20:00:37 -05:00
ᡠᠵᡠᡳ ᡠᠵᡠ ᠮᠠᠨᡩ᠋ᠠᠨ
ce9fc58b8d Skip protocol warning since QUIC supports multiplexing too (#8563) 2024-10-31 09:27:31 +00:00