SpeculativeLoadingParameters.Builder


public final class SpeculativeLoadingParameters.Builder


A builder class to use to construct the SpeculativeLoadingParameters.

Summary

Public constructors

Public methods

@NonNull SpeculativeLoadingParameters.Builder

Sets the header value for the given key.

@NonNull SpeculativeLoadingParameters.Builder

Sets multiple headers at once.

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

Use to finish building the PrefetchParams

@NonNull SpeculativeLoadingParameters.Builder

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

@NonNull SpeculativeLoadingParameters.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 SpeculativeLoadingParameters.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.

addAdditionalHeaders

@Profile.ExperimentalUrlPrefetch
public @NonNull SpeculativeLoadingParameters.Builder addAdditionalHeaders(@NonNull Map<StringString> additionalHeaders)

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

Use to finish building the PrefetchParams

Returns
@NonNull SpeculativeLoadingParameters

built PrefetchParams object.

setExpectedNoVarySearchData

@Profile.ExperimentalUrlPrefetch
public @NonNull SpeculativeLoadingParameters.Builder setExpectedNoVarySearchData(
    @NonNull NoVarySearchHeader expectedNoVarySearchHeader
)

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 SpeculativeLoadingParameters.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.