PrefetchParameters.Builder


public final class PrefetchParameters.Builder


A builder class to use to construct the PrefetchParameters.

Summary

Public constructors

Public methods

@NonNull PrefetchParameters.Builder

Sets the header value for the given key.

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

Use to finish building the PrefetchParams

@NonNull PrefetchParameters.Builder

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

@NonNull PrefetchParameters.Builder

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

Public constructors

Builder

public Builder()

Public methods

addAdditionalHeader

@Profile.ExperimentalUrlPrefetch
public @NonNull PrefetchParameters.Builder addAdditionalHeader(@NonNull String key, @NonNull String value)

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
public @NonNull PrefetchParameters build()

Use to finish building the PrefetchParams

Returns
@NonNull PrefetchParameters

built PrefetchParams object.

setExpectedNoVarySearchData

@Profile.ExperimentalUrlPrefetch
public @NonNull PrefetchParameters.Builder setExpectedNoVarySearchData(
    @NonNull NoVarySearchData expectedNoVarySearchData
)

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
public @NonNull PrefetchParameters.Builder setJavaScriptEnabled(boolean javaScriptEnabled)

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.