Builder
class Builder
| kotlin.Any | |
| ↳ | android.net.http.DnsOptions.StaleDnsOptions.Builder |
Builder for StaleDnsOptions.
Summary
| Public constructors | |
|---|---|
Builder() |
|
| Public methods | |
|---|---|
| DnsOptions.StaleDnsOptions |
build()Creates and returns the final |
| DnsOptions.StaleDnsOptions.Builder |
setAllowCrossNetworkUsage(state: Int)Sets whether to return results originating from other networks or not. |
| DnsOptions.StaleDnsOptions.Builder |
setFreshLookupTimeout(freshLookupTimeout: Duration)Sets how long (in milliseconds) to wait for a DNS request to return before using a stale result instead. |
| DnsOptions.StaleDnsOptions.Builder |
setMaxExpiredDelay(maxExpiredDelay: Duration)Sets how long (in milliseconds) past expiration to consider using expired results. |
| DnsOptions.StaleDnsOptions.Builder |
setUseStaleOnNameNotResolved(state: Int)Sets whether to allow use of stale DNS results when network resolver fails to resolve the hostname. |
Public constructors
Public methods
build
fun build(): DnsOptions.StaleDnsOptions
Creates and returns the final StaleDnsOptions instance, based on the values in this builder.
| Return | |
|---|---|
DnsOptions.StaleDnsOptions |
This value cannot be null. |
setAllowCrossNetworkUsage
fun setAllowCrossNetworkUsage(state: Int): DnsOptions.StaleDnsOptions.Builder
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 android.net.http.DnsOptions#DNS_OPTION_UNSPECIFIED, android.net.http.DnsOptions#DNS_OPTION_ENABLED, or android.net.http.DnsOptions#DNS_OPTION_DISABLED |
| Return | |
|---|---|
DnsOptions.StaleDnsOptions.Builder |
the builder for chaining This value cannot be null. |
setFreshLookupTimeout
fun setFreshLookupTimeout(freshLookupTimeout: Duration): DnsOptions.StaleDnsOptions.Builder
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. |
| Return | |
|---|---|
DnsOptions.StaleDnsOptions.Builder |
the builder for chaining This value cannot be null. |
setMaxExpiredDelay
fun setMaxExpiredDelay(maxExpiredDelay: Duration): DnsOptions.StaleDnsOptions.Builder
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. |
| Return | |
|---|---|
DnsOptions.StaleDnsOptions.Builder |
the builder for chaining This value cannot be null. |
setUseStaleOnNameNotResolved
fun setUseStaleOnNameNotResolved(state: Int): DnsOptions.StaleDnsOptions.Builder
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 android.net.http.DnsOptions#DNS_OPTION_UNSPECIFIED, android.net.http.DnsOptions#DNS_OPTION_ENABLED, or android.net.http.DnsOptions#DNS_OPTION_DISABLED |
| Return | |
|---|---|
DnsOptions.StaleDnsOptions.Builder |
the builder for chaining This value cannot be null. |