QuicOptions.Builder

class QuicOptions.Builder


Builder for QuicOptions.

Summary

Public functions

QuicOptions.Builder!

Adds a host to the QUIC allowlist.

QuicOptions.Builder!

Adds a QUIC tag to send in a QUIC handshake's connection options that only affects the client.

QuicOptions.Builder!

Adds a QUIC tag to send in a QUIC handshake's connection options.

QuicOptions.Builder!

Adds a QUIC version to the list of QUIC versions to enable.

QuicOptions.Builder!

Sets an arbitrary QUICHE flag.

QuicOptions!

Creates and returns the final QuicOptions instance, based on the values in this builder.

QuicOptions.Builder!

Sets whether QUIC sessions should be closed on IP address change.

QuicOptions.Builder!
@QuicOptions.Experimental
delayJobsWithAvailableSpdySession(
    delayJobsWithAvailableSpdySession: Boolean
)

Sets whether Cronet should wait for the primary path (usually QUIC) to be ready even if there's a secondary path of reaching the server (SPDY / HTTP2) which is ready immediately.

QuicOptions.Builder!

Sets whether TLS with 0-RTT should be enabled.

QuicOptions.Builder!

Sets whether QUIC sessions should be goaway'd on IP address change.

QuicOptions.Builder!
@QuicOptions.Experimental
increaseBrokenServicePeriodExponentially(
    increaseBrokenServicePeriodExponentially: Boolean
)

Sets whether the broken server period should scale exponentially.

QuicOptions.Builder!

Sets whether requests that failed with a QUIC protocol errors should be retried without using any alt-svc servers.

QuicOptions.Builder!

Sets the timeout for a connection SSL handshake.

QuicOptions.Builder!
setHandshakeUserAgent(handshakeUserAgent: String!)

Sets the user agent to be used outside of HTTP requests (for example for QUIC handshakes).

QuicOptions.Builder!
@RequiresApi(value = VERSION_CODES.O)
setIdleConnectionTimeout(idleConnectionTimeout: Duration)

Same as setIdleConnectionTimeoutSeconds but using java.time.Duration.

QuicOptions.Builder!
setIdleConnectionTimeoutSeconds(idleConnectionTimeoutSeconds: Long)

Sets the maximum idle time for a connection.

QuicOptions.Builder!
setInMemoryServerConfigsCacheSize(inMemoryServerConfigsCacheSize: Int)

Sets how many server configurations (metadata like list of alt svc, whether QUIC is supported, etc.) should be held in memory.

QuicOptions.Builder!
@QuicOptions.Experimental
setInitialBrokenServicePeriodSeconds(
    initialBrokenServicePeriodSeconds: Long
)

Sets the initial for which Cronet shouldn't attempt to use QUIC for a given server after the server's QUIC support turned out to be broken.

QuicOptions.Builder!
@QuicOptions.Experimental
setPreCryptoHandshakeIdleTimeoutSeconds(
    preCryptoHandshakeIdleTimeoutSeconds: Long
)

Sets the maximum idle time for a connection which hasn't completed a SSL handshake yet.

QuicOptions.Builder!
@QuicOptions.Experimental
setRetransmittableOnWireTimeoutMillis(
    retransmittableOnWireTimeoutMillis: Long
)

Sets the maximum desired time between packets on wire.

Public functions

addAllowedQuicHost

fun addAllowedQuicHost(quicHost: String!): QuicOptions.Builder!

Adds a host to the QUIC allowlist.

If no hosts are specified, the per-host allowlist functionality is disabled. Otherwise, Cronet will only use QUIC when talking to hosts on the allowlist.

Returns
QuicOptions.Builder!

the builder for chaining

addClientConnectionOption

@QuicOptions.QuichePassthroughOption
fun addClientConnectionOption(clientConnectionOption: String!): QuicOptions.Builder!

Adds a QUIC tag to send in a QUIC handshake's connection options that only affects the client.

See addConnectionOption for more details.

addConnectionOption

@QuicOptions.QuichePassthroughOption
fun addConnectionOption(connectionOption: String!): QuicOptions.Builder!

Adds a QUIC tag to send in a QUIC handshake's connection options.

The QUIC tags should be presented as strings up to four letters long (for instance, NBHD).

As the QUIC tags are under active development and some are only relevant to the server, Cronet doesn't attempt to maintain a complete list of all supported QUIC flags as a part of the API. The flags. Flags supported by QUICHE, a QUIC implementation used by Cronet and Google servers, can be found here.

Returns
QuicOptions.Builder!

the builder for chaining

addEnabledQuicVersion

@QuicOptions.QuichePassthroughOption
fun addEnabledQuicVersion(enabledQuicVersion: String!): QuicOptions.Builder!

Adds a QUIC version to the list of QUIC versions to enable.

If no versions are specified, Cronet will use a list of default QUIC versions.

The version format is specified by QUICHE. Outside of filtering out values known to be obsolete, Cronet doesn't process the versions anyhow and simply passes them along to QUICHE.

Returns
QuicOptions.Builder!

the builder for chaining

addExtraQuicheFlag

@QuicOptions.QuichePassthroughOption
fun addExtraQuicheFlag(extraQuicheFlag: String!): QuicOptions.Builder!

Sets an arbitrary QUICHE flag. Flags should be passed in FLAG_NAME=FLAG_VALUE format. See the QUICHE code base for a full list of flags.

Returns
QuicOptions.Builder!

the builder for chaining

build

fun build(): QuicOptions!

Creates and returns the final QuicOptions instance, based on the values in this builder.

closeSessionsOnIpChange

@QuicOptions.Experimental
fun closeSessionsOnIpChange(closeSessionsOnIpChange: Boolean): QuicOptions.Builder!

Sets whether QUIC sessions should be closed on IP address change.

Don't use in combination with connection migration (configured using ConnectionMigrationOptions).

Returns
QuicOptions.Builder!

the builder for chaining

delayJobsWithAvailableSpdySession

@QuicOptions.Experimental
fun delayJobsWithAvailableSpdySession(
    delayJobsWithAvailableSpdySession: Boolean
): QuicOptions.Builder!

Sets whether Cronet should wait for the primary path (usually QUIC) to be ready even if there's a secondary path of reaching the server (SPDY / HTTP2) which is ready immediately.

Returns
QuicOptions.Builder!

the builder for chaining

enableTlsZeroRtt

@QuicOptions.Experimental
fun enableTlsZeroRtt(enableTlsZeroRtt: Boolean): QuicOptions.Builder!

Sets whether TLS with 0-RTT should be enabled.

0-RTT is a performance optimization avoiding an extra round trip when resuming connections to a known server.

Returns
QuicOptions.Builder!

the builder for chaining

goawaySessionsOnIpChange

@QuicOptions.Experimental
fun goawaySessionsOnIpChange(goawaySessionsOnIpChange: Boolean): QuicOptions.Builder!

Sets whether QUIC sessions should be goaway'd on IP address change.

Don't use in combination with connection migration (configured using ConnectionMigrationOptions).

Returns
QuicOptions.Builder!

the builder for chaining

increaseBrokenServicePeriodExponentially

@QuicOptions.Experimental
fun increaseBrokenServicePeriodExponentially(
    increaseBrokenServicePeriodExponentially: Boolean
): QuicOptions.Builder!

Sets whether the broken server period should scale exponentially.

If set to true, the initial delay (configurable by setInitialBrokenServicePeriodSeconds) will be scaled exponentially for subsequent retries (SCALING_FACTOR^NUM_TRIES * delay). If false, the delay will scale linearly (SCALING_FACTOR * NUM_TRIES * delay).

Returns
QuicOptions.Builder!

the builder for chaining

retryWithoutAltSvcOnQuicErrors

@QuicOptions.Experimental
fun retryWithoutAltSvcOnQuicErrors(retryWithoutAltSvcOnQuicErrors: Boolean): QuicOptions.Builder!

Sets whether requests that failed with a QUIC protocol errors should be retried without using any alt-svc servers.

Returns
QuicOptions.Builder!

the builder for chaining

setCryptoHandshakeTimeoutSeconds

@QuicOptions.Experimental
fun setCryptoHandshakeTimeoutSeconds(cryptoHandshakeTimeoutSeconds: Long): QuicOptions.Builder!

Sets the timeout for a connection SSL handshake.

Returns
QuicOptions.Builder!

the builder for chaining

setHandshakeUserAgent

fun setHandshakeUserAgent(handshakeUserAgent: String!): QuicOptions.Builder!

Sets the user agent to be used outside of HTTP requests (for example for QUIC handshakes).

To set the default user agent for HTTP requests, use setUserAgent instead.

Returns
QuicOptions.Builder!

the builder for chaining

setIdleConnectionTimeout

@RequiresApi(value = VERSION_CODES.O)
fun setIdleConnectionTimeout(idleConnectionTimeout: Duration): QuicOptions.Builder!

Same as setIdleConnectionTimeoutSeconds but using java.time.Duration.

Returns
QuicOptions.Builder!

the builder for chaining

setIdleConnectionTimeoutSeconds

fun setIdleConnectionTimeoutSeconds(idleConnectionTimeoutSeconds: Long): QuicOptions.Builder!

Sets the maximum idle time for a connection. The actual value for the idle timeout is the minimum of this value and the server's and is negotiated during the handshake. Thus, it only applies after the handshake has completed. If no activity is detected on the connection for the set duration, the connection is closed.

See RFC 9114, section 5.1 for more details.

Returns
QuicOptions.Builder!

the builder for chaining

setInMemoryServerConfigsCacheSize

fun setInMemoryServerConfigsCacheSize(inMemoryServerConfigsCacheSize: Int): QuicOptions.Builder!

Sets how many server configurations (metadata like list of alt svc, whether QUIC is supported, etc.) should be held in memory.

If the storage path is set (setStoragePath, Cronet will also persist the server configurations on disk.

Returns
QuicOptions.Builder!

the builder for chaining

setInitialBrokenServicePeriodSeconds

@QuicOptions.Experimental
fun setInitialBrokenServicePeriodSeconds(
    initialBrokenServicePeriodSeconds: Long
): QuicOptions.Builder!

Sets the initial for which Cronet shouldn't attempt to use QUIC for a given server after the server's QUIC support turned out to be broken.

Once Cronet detects that a server advertises QUIC but doesn't actually speak it, it marks the server as broken and doesn't attempt to use QUIC when talking to the server for an amount of time. Once Cronet is past this point it will try using QUIC again. This is to balance short term (there's no point wasting resources to try QUIC if the server is broken) and long term (the breakage might have been temporary, using QUIC is generally beneficial) interests.

The delay is increased every unsuccessful consecutive retry. See increaseBrokenServicePeriodExponentially for details.

Returns
QuicOptions.Builder!

the builder for chaining

setPreCryptoHandshakeIdleTimeoutSeconds

@QuicOptions.Experimental
fun setPreCryptoHandshakeIdleTimeoutSeconds(
    preCryptoHandshakeIdleTimeoutSeconds: Long
): QuicOptions.Builder!

Sets the maximum idle time for a connection which hasn't completed a SSL handshake yet.

Returns
QuicOptions.Builder!

the builder for chaining

setRetransmittableOnWireTimeoutMillis

@QuicOptions.Experimental
fun setRetransmittableOnWireTimeoutMillis(
    retransmittableOnWireTimeoutMillis: Long
): QuicOptions.Builder!

Sets the maximum desired time between packets on wire.

When the retransmittable-on-wire time is exceeded Cronet will probe quality of the network using artificial traffic. Smaller timeouts will typically result in faster discovery of a broken or degrading path, but also larger usage of resources (battery, data).

Returns
QuicOptions.Builder!

the builder for chaining