PrefetchParameters.Builder


class PrefetchParameters.Builder


A builder class to use to construct the PrefetchParameters.

Summary

Public constructors

Public functions

PrefetchParameters.Builder

Sets the header value for the given key.

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

Use to finish building the PrefetchParams

PrefetchParameters.Builder

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

PrefetchParameters.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): PrefetchParameters.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.

build

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

Use to finish building the PrefetchParams

Returns
PrefetchParameters

built PrefetchParams object.

setExpectedNoVarySearchData

@Profile.ExperimentalUrlPrefetch
fun setExpectedNoVarySearchData(expectedNoVarySearchData: NoVarySearchData): PrefetchParameters.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): PrefetchParameters.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.