public class DnsOverHttps extends java.lang.Object implements Dns
A DNS API client encodes a single DNS query into an HTTP request using either the HTTP GET or POST method and the other requirements of this section. The DNS API server defines the URI used by the request through the use of a URI Template.
As of OkHttp 3.11, this feature is an unstable preview: the API is subject to change, and the implementation is incomplete. We expect that OkHttp 3.12 or 3.13 will finalize this API. Until then, expect API and behavior changes when you update your OkHttp dependency.
Modifier and Type | Class and Description |
---|---|
static class |
DnsOverHttps.Builder |
Modifier and Type | Field and Description |
---|---|
private OkHttpClient |
client |
static MediaType |
DNS_MESSAGE |
private boolean |
includeIPv6 |
static int |
MAX_RESPONSE_SIZE |
private boolean |
post |
private boolean |
resolvePrivateAddresses |
private boolean |
resolvePublicAddresses |
private HttpUrl |
url |
Constructor and Description |
---|
DnsOverHttps(DnsOverHttps.Builder builder) |
Modifier and Type | Method and Description |
---|---|
private static Dns |
buildBootstrapClient(DnsOverHttps.Builder builder) |
private Request |
buildRequest(java.lang.String hostname,
int type) |
private void |
buildRequest(java.lang.String hostname,
java.util.List<Call> networkRequests,
java.util.List<java.net.InetAddress> results,
java.util.List<java.lang.Exception> failures,
int type) |
OkHttpClient |
client() |
private void |
executeRequests(java.lang.String hostname,
java.util.List<Call> networkRequests,
java.util.List<java.net.InetAddress> responses,
java.util.List<java.lang.Exception> failures) |
private Response |
getCacheOnlyResponse(Request request) |
boolean |
includeIPv6() |
(package private) static boolean |
isPrivateHost(java.lang.String host) |
java.util.List<java.net.InetAddress> |
lookup(java.lang.String hostname)
Returns the IP addresses of
hostname , in the order they will be attempted by OkHttp. |
private java.util.List<java.net.InetAddress> |
lookupHttps(java.lang.String hostname) |
boolean |
post() |
private void |
processResponse(Response response,
java.lang.String hostname,
java.util.List<java.net.InetAddress> results,
java.util.List<java.lang.Exception> failures) |
private java.util.List<java.net.InetAddress> |
readResponse(java.lang.String hostname,
Response response) |
boolean |
resolvePrivateAddresses() |
boolean |
resolvePublicAddresses() |
private java.util.List<java.net.InetAddress> |
throwBestFailure(java.lang.String hostname,
java.util.List<java.lang.Exception> failures) |
HttpUrl |
url() |
public static final MediaType DNS_MESSAGE
public static final int MAX_RESPONSE_SIZE
private final OkHttpClient client
private final HttpUrl url
private final boolean includeIPv6
private final boolean post
private final boolean resolvePrivateAddresses
private final boolean resolvePublicAddresses
DnsOverHttps(DnsOverHttps.Builder builder)
private static Dns buildBootstrapClient(DnsOverHttps.Builder builder)
public HttpUrl url()
public boolean post()
public boolean includeIPv6()
public OkHttpClient client()
public boolean resolvePrivateAddresses()
public boolean resolvePublicAddresses()
public java.util.List<java.net.InetAddress> lookup(java.lang.String hostname) throws java.net.UnknownHostException
Dns
hostname
, in the order they will be attempted by OkHttp. If
a connection to an address fails, OkHttp will retry the connection with the next address until
either a connection is made, the set of IP addresses is exhausted, or a limit is exceeded.private java.util.List<java.net.InetAddress> lookupHttps(java.lang.String hostname) throws java.net.UnknownHostException
java.net.UnknownHostException
private void buildRequest(java.lang.String hostname, java.util.List<Call> networkRequests, java.util.List<java.net.InetAddress> results, java.util.List<java.lang.Exception> failures, int type)
private void executeRequests(java.lang.String hostname, java.util.List<Call> networkRequests, java.util.List<java.net.InetAddress> responses, java.util.List<java.lang.Exception> failures)
private void processResponse(Response response, java.lang.String hostname, java.util.List<java.net.InetAddress> results, java.util.List<java.lang.Exception> failures)
private java.util.List<java.net.InetAddress> throwBestFailure(java.lang.String hostname, java.util.List<java.lang.Exception> failures) throws java.net.UnknownHostException
java.net.UnknownHostException
private java.util.List<java.net.InetAddress> readResponse(java.lang.String hostname, Response response) throws java.lang.Exception
java.lang.Exception
private Request buildRequest(java.lang.String hostname, int type)
static boolean isPrivateHost(java.lang.String host)