# QuicOptions.Builder

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[S Extensions 7](https://developer.android.com/sdkExtensions)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/net/http/QuicOptions.Builder "View this page in Java")  

```
class Builder
```

|---|------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                               ||
| ↳ | [android.net.http.QuicOptions.Builder](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#) |

Builder for[QuicOptions](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions).

## Summary

|                                                  Public constructors                                                   ||
|---------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#Builder())`()` <br /> |

|                                                                                                                                                                                                                                                            Public methods                                                                                                                                                                                                                                                            ||
|-------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [QuicOptions.Builder](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#) | [addAllowedQuicHost](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#addAllowedQuicHost(kotlin.String))`(`quicHost:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Adds a host to the QUIC allowlist.                                                                                                                                        |
| [QuicOptions](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions)                  | [build](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#build())`()` Creates and returns the final[QuicOptions](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions)instance, based on the values in this builder.                                                                                                                                          |
| [QuicOptions.Builder](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#) | [setHandshakeUserAgent](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#setHandshakeUserAgent(kotlin.String))`(`handshakeUserAgent:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Sets the user agent to be used outside of HTTP requests (for example for QUIC handshakes).                                                                |
| [QuicOptions.Builder](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#) | [setIdleConnectionTimeout](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#setIdleConnectionTimeout(java.time.Duration))`(`idleConnectionTimeout:` `[Duration](https://developer.android.com/reference/kotlin/java/time/Duration.html#)`)` Sets the maximum idle time for a connection.                                                                                             |
| [QuicOptions.Builder](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#) | [setInMemoryServerConfigsCacheSize](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#setInMemoryServerConfigsCacheSize(kotlin.Int))`(`inMemoryServerConfigsCacheSize:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets how many server configurations (metadata like list of alt svc, whether QUIC is supported, etc.) should be held in memory. |

## Public constructors

### Builder

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[S Extensions 7](https://developer.android.com/sdkExtensions)  

```
Builder()
```

## Public methods

### addAllowedQuicHost

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[S Extensions 7](https://developer.android.com/sdkExtensions)  

```
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, the HTTP stack will only use QUIC when talking to hosts on the allowlist.

|                                                        Parameters                                                        ||
|------------|--------------------------------------------------------------------------------------------------------------|
| `quicHost` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`. |

|                                                                              Return                                                                               ||
|-------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [QuicOptions.Builder](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#) | the builder for chaining This value cannot be`null`. |

### build

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[S Extensions 7](https://developer.android.com/sdkExtensions)  

```
fun build(): QuicOptions
```

Creates and returns the final[QuicOptions](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions)instance, based on the values in this builder.

|                                                         Return                                                          ||
|--------------------------------------------------------------------------------------------|-----------------------------|
| [QuicOptions](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions) | This value cannot be`null`. |

### setHandshakeUserAgent

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[S Extensions 7](https://developer.android.com/sdkExtensions)  

```
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[HttpEngine.Builder.setUserAgent(String)](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setUserAgent(kotlin.String))instead.

|                                                             Parameters                                                             ||
|----------------------|--------------------------------------------------------------------------------------------------------------|
| `handshakeUserAgent` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`. |

|                                                                              Return                                                                               ||
|-------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [QuicOptions.Builder](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#) | the builder for chaining This value cannot be`null`. |

### setIdleConnectionTimeout

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[S Extensions 7](https://developer.android.com/sdkExtensions)  

```
fun setIdleConnectionTimeout(idleConnectionTimeout: Duration): 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](https://www.rfc-editor.org/rfc/rfc9114.html#name-idle-connections)for more details.

|                                                                Parameters                                                                ||
|-------------------------|-----------------------------------------------------------------------------------------------------------------|
| `idleConnectionTimeout` | [Duration](https://developer.android.com/reference/kotlin/java/time/Duration.html#):This value cannot be`null`. |

|                                                                              Return                                                                               ||
|-------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [QuicOptions.Builder](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#) | the builder for chaining This value cannot be`null`. |

### setInMemoryServerConfigsCacheSize

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[S Extensions 7](https://developer.android.com/sdkExtensions)  

```
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 ([HttpEngine.Builder.setStoragePath(String)](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setStoragePath(kotlin.String)), the HTTP stack will also persist the server configurations on disk.

|                                                                              Return                                                                               ||
|-------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [QuicOptions.Builder](https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder#) | the builder for chaining This value cannot be`null`. |