Builder


class Builder
kotlin.Any
   ↳ android.net.http.DnsOptions.Builder

Builder for DnsOptions.

Summary

Public constructors

Public methods
DnsOptions

Creates and returns the final DnsOptions instance, based on the values in this builder.

DnsOptions.Builder

Sets whether the DNS cache should be persisted to disk.

DnsOptions.Builder
setPersistHostCachePeriod(persistHostCachePeriod: Duration)

Sets the minimum period between subsequent writes to disk for DNS cache persistence.

DnsOptions.Builder

Sets whether Cronet should use stale cached DNS records to pre-establish connections.

DnsOptions.Builder
setStaleDns(state: Int)

Sets whether to use stale DNS results at all.

DnsOptions.Builder

Sets detailed configuration for stale DNS.

DnsOptions.Builder

Enables the use of the HTTP-stack-specific DNS resolver.

Public constructors

Builder

Builder()

Public methods

build

fun build(): DnsOptions

Creates and returns the final DnsOptions instance, based on the values in this builder.

Return
DnsOptions This value cannot be null.

setPersistHostCache

fun setPersistHostCache(state: Int): DnsOptions.Builder

Sets whether the DNS cache should be persisted to disk.

Only relevant if HttpEngine.Builder.setStoragePath(String) is set.

Parameters
state Int: one of the DNS_OPTION_* values Value is android.net.http.DnsOptions#DNS_OPTION_UNSPECIFIED, android.net.http.DnsOptions#DNS_OPTION_ENABLED, or android.net.http.DnsOptions#DNS_OPTION_DISABLED
Return
DnsOptions.Builder the builder for chaining This value cannot be null.

setPersistHostCachePeriod

fun setPersistHostCachePeriod(persistHostCachePeriod: Duration): DnsOptions.Builder

Sets the minimum period between subsequent writes to disk for DNS cache persistence.

Only relevant if setPersistHostCache(int) is set to DNS_OPTION_ENABLED.

Parameters
persistHostCachePeriod Duration: This value cannot be null.
Return
DnsOptions.Builder the builder for chaining This value cannot be null.

setPreestablishConnectionsToStaleDnsResults

fun setPreestablishConnectionsToStaleDnsResults(state: Int): DnsOptions.Builder

Sets whether Cronet should use stale cached DNS records to pre-establish connections.

If enabled, Cronet will optimistically pre-establish connections to servers that matched the hostname at some point in the past and were cached but the cache entry expired. Such connections won't be used further until a new DNS lookup confirms the cached record was up to date.

To use cached DNS records straight away, use setStaleDns(int) and StaleDnsOptions configuration options.

This option may not be available for all networking protocols.

Parameters
state Int: one of the DNS_OPTION_* values Value is android.net.http.DnsOptions#DNS_OPTION_UNSPECIFIED, android.net.http.DnsOptions#DNS_OPTION_ENABLED, or android.net.http.DnsOptions#DNS_OPTION_DISABLED
Return
DnsOptions.Builder the builder for chaining This value cannot be null.

setStaleDns

fun setStaleDns(state: Int): DnsOptions.Builder

Sets whether to use stale DNS results at all.

Parameters
state Int: one of the DNS_OPTION_* values Value is android.net.http.DnsOptions#DNS_OPTION_UNSPECIFIED, android.net.http.DnsOptions#DNS_OPTION_ENABLED, or android.net.http.DnsOptions#DNS_OPTION_DISABLED
Return
DnsOptions.Builder the builder for chaining This value cannot be null.

setStaleDnsOptions

fun setStaleDnsOptions(staleDnsOptions: DnsOptions.StaleDnsOptions): DnsOptions.Builder

Sets detailed configuration for stale DNS. Only relevant if setStaleDns(int) is set.

Parameters
staleDnsOptions DnsOptions.StaleDnsOptions: This value cannot be null.
Return
DnsOptions.Builder this builder for chaining. This value cannot be null.

setUseHttpStackDnsResolver

fun setUseHttpStackDnsResolver(state: Int): DnsOptions.Builder

Enables the use of the HTTP-stack-specific DNS resolver.

Setting this to DNS_OPTION_ENABLED is necessary for other functionality of DnsOptions to work, unless specified otherwise. See the DnsOptions documentation for more details.

Parameters
state Int: one of the DNS_OPTION_* values Value is android.net.http.DnsOptions#DNS_OPTION_UNSPECIFIED, android.net.http.DnsOptions#DNS_OPTION_ENABLED, or android.net.http.DnsOptions#DNS_OPTION_DISABLED
Return
DnsOptions.Builder the builder for chaining This value cannot be null.