DnsOptions.StaleDnsOptions.Builder


public static final class DnsOptions.StaleDnsOptions.Builder
extends Object

java.lang.Object
   ↳ android.net.http.DnsOptions.StaleDnsOptions.Builder


Builder for StaleDnsOptions.

Summary

Public constructors

Builder()

Public methods

DnsOptions.StaleDnsOptions build()

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

DnsOptions.StaleDnsOptions.Builder setAllowCrossNetworkUsage(int state)

Sets whether to return results originating from other networks or not.

DnsOptions.StaleDnsOptions.Builder setFreshLookupTimeout(Duration freshLookupTimeout)

Sets how long (in milliseconds) to wait for a DNS request to return before using a stale result instead.

DnsOptions.StaleDnsOptions.Builder setMaxExpiredDelay(Duration maxExpiredDelay)

Sets how long (in milliseconds) past expiration to consider using expired results.

DnsOptions.StaleDnsOptions.Builder setUseStaleOnNameNotResolved(int state)

Sets whether to allow use of stale DNS results when network resolver fails to resolve the hostname.

Inherited methods

Public constructors

Builder

Added in API level 34
Also in S Extensions 7
public Builder ()

Public methods

build

Added in API level 34
Also in S Extensions 7
public DnsOptions.StaleDnsOptions build ()

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

Returns
DnsOptions.StaleDnsOptions This value cannot be null.

setAllowCrossNetworkUsage

Added in API level 34
Also in S Extensions 7
public DnsOptions.StaleDnsOptions.Builder setAllowCrossNetworkUsage (int state)

Sets whether to return results originating from other networks or not. Normally, the HTTP stack clears the DNS cache entirely when switching connections, e.g. between two Wi-Fi networks or from Wi-Fi to 4G.

Parameters
state int: one of the DNS_OPTION_* values Value is DnsOptions.DNS_OPTION_UNSPECIFIED, DnsOptions.DNS_OPTION_ENABLED, or DnsOptions.DNS_OPTION_DISABLED

Returns
DnsOptions.StaleDnsOptions.Builder the builder for chaining This value cannot be null.

setFreshLookupTimeout

Added in API level 34
Also in S Extensions 7
public DnsOptions.StaleDnsOptions.Builder setFreshLookupTimeout (Duration freshLookupTimeout)

Sets how long (in milliseconds) to wait for a DNS request to return before using a stale result instead. If set to zero, returns stale results instantly but continues the DNS request in the background to update the cache.

Parameters
freshLookupTimeout Duration: This value cannot be null.

Returns
DnsOptions.StaleDnsOptions.Builder the builder for chaining This value cannot be null.

setMaxExpiredDelay

Added in API level 34
Also in S Extensions 7
public DnsOptions.StaleDnsOptions.Builder setMaxExpiredDelay (Duration maxExpiredDelay)

Sets how long (in milliseconds) past expiration to consider using expired results. Setting the value to zero means expired records can be used indefinitely.

Parameters
maxExpiredDelay Duration: This value cannot be null.

Returns
DnsOptions.StaleDnsOptions.Builder the builder for chaining This value cannot be null.

setUseStaleOnNameNotResolved

Added in API level 34
Also in S Extensions 7
public DnsOptions.StaleDnsOptions.Builder setUseStaleOnNameNotResolved (int state)

Sets whether to allow use of stale DNS results when network resolver fails to resolve the hostname.

Depending on the use case, if the DNS resolver quickly sees a fresh failure, it may be desirable to use the failure as it is technically the fresher result, and we had such a fresh result quickly; or, prefer having any result (even if stale) to use over dealing with a DNS failure.

Parameters
state int: one of the DNS_OPTION_* values Value is DnsOptions.DNS_OPTION_UNSPECIFIED, DnsOptions.DNS_OPTION_ENABLED, or DnsOptions.DNS_OPTION_DISABLED

Returns
DnsOptions.StaleDnsOptions.Builder the builder for chaining This value cannot be null.