SpeculativeLoadingParameters.Builder


class SpeculativeLoadingParameters.Builder


A builder class to use to construct the SpeculativeLoadingParameters.

Summary

Public constructors

Public functions

SpeculativeLoadingParameters.Builder

Sets the header value for the given key.

SpeculativeLoadingParameters.Builder

Sets multiple headers at once.

SpeculativeLoadingParameters
@RequiresFeature(name = WebViewFeature.PROFILE_URL_PREFETCH, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@Profile.ExperimentalUrlPrefetch
build()

Use to finish building the PrefetchParams

SpeculativeLoadingParameters.Builder

Sets the "No-Vary-Search data that's expected to be returned via. the header in the prefetch's response.

SpeculativeLoadingParameters.Builder

true if the WebView's that will be loading the prefetched response will have javascript enabled.

Public constructors

Builder

Builder()

Public functions

addAdditionalHeader

@Profile.ExperimentalUrlPrefetch
fun addAdditionalHeader(key: String, value: String): SpeculativeLoadingParameters.Builder

Sets the header value for the given key. If called multiple times for the same key, the latest value will be used.

Header keys must be RFC 2616-compliant.

addAdditionalHeaders

@Profile.ExperimentalUrlPrefetch
fun addAdditionalHeaders(additionalHeaders: (Mutable)Map<String!, String!>): SpeculativeLoadingParameters.Builder

Sets multiple headers at once. The headers passed in here will be merged with any that have been previously set (duplicate keys will be overridden).

Header keys must be RFC 2616-compliant.

build

@RequiresFeature(name = WebViewFeature.PROFILE_URL_PREFETCH, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@Profile.ExperimentalUrlPrefetch
fun build(): SpeculativeLoadingParameters

Use to finish building the PrefetchParams

Returns
SpeculativeLoadingParameters

built PrefetchParams object.

setExpectedNoVarySearchData

@Profile.ExperimentalUrlPrefetch
fun setExpectedNoVarySearchData(
    expectedNoVarySearchHeader: NoVarySearchHeader
): SpeculativeLoadingParameters.Builder

Sets the "No-Vary-Search data that's expected to be returned via. the header in the prefetch's response. This is used to help determine if WebView#loadUrl should either use an in-flight prefetch response to render the web contents or handle the URL as it typically does (i.e. start a network request).

setJavaScriptEnabled

@Profile.ExperimentalUrlPrefetch
fun setJavaScriptEnabled(javaScriptEnabled: Boolean): SpeculativeLoadingParameters.Builder

true if the WebView's that will be loading the prefetched response will have javascript enabled. This affects whether or not client hints header is sent with the prefetch request.