PrerenderParameters.Builder


public final class PrerenderParameters.Builder


A builder class to use to construct the PrerenderParameters.

Summary

Public constructors

Construct a new Builder.

Public methods

@NonNull PrerenderParameters.Builder

Sets the header value for the given key.

@NonNull PrerenderParameters.Builder

Sets multiple headers at once.

@NonNull PrerenderParameters

Build the PrerenderParameters.

@NonNull PrerenderParameters.Builder

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

@NonNull PrerenderParameters.Builder

Sets an optional variations ID to associate with this prefetch request.

Public constructors

Builder

public Builder()

Construct a new Builder.

Public methods

addAdditionalHeader

@Profile.ExperimentalUrlPrefetch
public @NonNull PrerenderParameters.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 last value will be used.

Header keys must be RFC 2616 -compliant.

The logic for handling additional header isn't guaranteed to match the loadUrl's logic and is subject to change in the future.

Parameters
@NonNull String key

The header key.

@NonNull String value

The header value.

Returns
@NonNull PrerenderParameters.Builder

This builder instance for chaining.

addAdditionalHeaders

@Profile.ExperimentalUrlPrefetch
public @NonNull PrerenderParameters.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.

Parameters
@NonNull Map<StringString> additionalHeaders

A map of additional headers to set.

Returns
@NonNull PrerenderParameters.Builder

This builder instance for chaining.

setExpectedNoVarySearchData

@Profile.ExperimentalUrlPrefetch
public @NonNull PrerenderParameters.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).

Parameters
@NonNull NoVarySearchHeader expectedNoVarySearchHeader

The No-Vary-Search data expected to be returned in the prefetch's response.

Returns
@NonNull PrerenderParameters.Builder

This builder instance for chaining.

setVariationsId

@Profile.ExperimentalUrlPrefetch
public @NonNull PrerenderParameters.Builder setVariationsId(@Nullable Integer variationsId)

Sets an optional variations ID to associate with this prefetch request.

Parameters
@Nullable Integer variationsId

An Integer ID for this prefetch configuration, or null if no specific variations ID is applicable.

Returns
@NonNull PrerenderParameters.Builder

This builder instance for chaining.