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

*** ** * ** ***

```
open class Builder
```

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

A builder for `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine`s, which allows runtime configuration of `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine`. Configuration options are set on the builder and then `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#build()` is called to create the `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine`.

## Summary

| Constants ||
|---|---|
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#HTTP_CACHE_DISABLED:kotlin.Int` Setting to disable HTTP cache. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#HTTP_CACHE_DISK:kotlin.Int` Setting to enable on-disk cache, including HTTP data. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#HTTP_CACHE_DISK_NO_HTTP:kotlin.Int` Setting to enable on-disk cache, excluding HTTP data. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#HTTP_CACHE_IN_MEMORY:kotlin.Int` Setting to enable in-memory HTTP cache, including HTTP data. |

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#Builder(android.content.Context)(context: https://developer.android.com/reference/kotlin/android/content/Context.html#)` Constructs a `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` object that facilitates creating a `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine`. |

| Public methods ||
|---|---|
| open [HttpEngine.Builder](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#addPublicKeyPins(kotlin.String,%20kotlin.collections.MutableSet,%20kotlin.Boolean,%20java.time.Instant)(hostName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, pinsSha256: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html!>, includeSubdomains: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html, expirationInstant: https://developer.android.com/reference/kotlin/java/time/Instant.html#)` Pins a set of public keys for a given host. |
| open [HttpEngine.Builder](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#addQuicHint(kotlin.String,%20kotlin.Int,%20kotlin.Int)(host: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, port: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, alternatePort: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Adds hint that `host` supports QUIC. |
| open [HttpEngine](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#build()()` Build a `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine` using this builder's configuration. |
| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#getDefaultUserAgent()()` Constructs a default User-Agent string including the system build version, model and id, and the HTTP stack version. |
| open [HttpEngine.Builder](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setConnectionMigrationOptions(android.net.http.ConnectionMigrationOptions)(options: https://developer.android.com/reference/kotlin/android/net/http/ConnectionMigrationOptions)` Configures the behavior of connection migration. |
| open [HttpEngine.Builder](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setDnsOptions(android.net.http.DnsOptions)(options: https://developer.android.com/reference/kotlin/android/net/http/DnsOptions)` Configures the behavior of hostname lookup. |
| open [HttpEngine.Builder](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setEnableBrotli(kotlin.Boolean)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets whether [Brotli](https://tools.ietf.org/html/rfc7932) compression is enabled. |
| open [HttpEngine.Builder](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setEnableHttp2(kotlin.Boolean)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets whether [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol is enabled. |
| open [HttpEngine.Builder](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setEnableHttpCache(kotlin.Int,%20kotlin.Long)(cacheMode: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, maxSize: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)` Enables or disables caching of HTTP data and other information like QUIC server information. |
| open [HttpEngine.Builder](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setEnablePublicKeyPinningBypassForLocalTrustAnchors(kotlin.Boolean)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Enables or disables public key pinning bypass for local trust anchors. |
| open [HttpEngine.Builder](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setEnableQuic(kotlin.Boolean)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Sets whether [QUIC](https://www.chromium.org/quic) protocol is enabled. |
| open [HttpEngine.Builder](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setProxyOptions(android.net.http.ProxyOptions)(options: https://developer.android.com/reference/kotlin/android/net/http/ProxyOptions)` Configures proxying behavior. |
| open [HttpEngine.Builder](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setQuicOptions(android.net.http.QuicOptions)(options: https://developer.android.com/reference/kotlin/android/net/http/QuicOptions)` Configures the behavior of the HTTP stack when using QUIC. |
| open [HttpEngine.Builder](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setStoragePath(kotlin.String)(value: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Sets directory for HTTP Cache and Cookie Storage. |
| open [HttpEngine.Builder](https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#) | `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setUserAgent(kotlin.String)(userAgent: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Overrides the User-Agent header for all requests. |

## Constants

### HTTP_CACHE_DISABLED

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)

```
static val HTTP_CACHE_DISABLED: Int
```

Setting to disable HTTP cache. Some data may still be temporarily stored in memory. Passed to `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setEnableHttpCache(kotlin.Int,%20kotlin.Long)`.

    Value: 0

### HTTP_CACHE_DISK

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)

```
static val HTTP_CACHE_DISK: Int
```

Setting to enable on-disk cache, including HTTP data. `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setStoragePath(kotlin.String)` must be called prior to passing this constant to `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setEnableHttpCache(kotlin.Int,%20kotlin.Long)`.

    Value: 3

### HTTP_CACHE_DISK_NO_HTTP

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)

```
static val HTTP_CACHE_DISK_NO_HTTP: Int
```

Setting to enable on-disk cache, excluding HTTP data. `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setStoragePath(kotlin.String)` must be called prior to passing this constant to `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setEnableHttpCache(kotlin.Int,%20kotlin.Long)`.

    Value: 2

### HTTP_CACHE_IN_MEMORY

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)

```
static val HTTP_CACHE_IN_MEMORY: Int
```

Setting to enable in-memory HTTP cache, including HTTP data. Passed to `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setEnableHttpCache(kotlin.Int,%20kotlin.Long)`.

    Value: 1

## 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(context: Context)
```

Constructs a `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` object that facilitates creating a `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine`. The default configuration enables HTTP/2 and QUIC, but disables the HTTP cache.

| Parameters ||
|---|---|
| `context` | [Context](https://developer.android.com/reference/kotlin/android/content/Context.html#): Android `https://developer.android.com/reference/kotlin/android/content/Context.html#`, which is used by `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` to retrieve the application context. A reference to only the application context will be kept, so as to avoid extending the lifetime of `context` unnecessarily. This value cannot be `null`. |

## Public methods

### addPublicKeyPins

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)

```
open fun addPublicKeyPins(
    hostName: String, 
    pinsSha256: MutableSet<ByteArray!>, 
    includeSubdomains: Boolean, 
    expirationInstant: Instant
): HttpEngine.Builder
```

Pins a set of public keys for a given host. By pinning a set of public keys, `pinsSha256`, communication with `hostName` is required to authenticate with a certificate with a public key from the set of pinned ones. An app can pin the public key of the root certificate, any of the intermediate certificates or the end-entry certificate. Authentication will fail and secure communication will not be established if none of the public keys is present in the host's certificate chain, even if the host attempts to authenticate with a certificate allowed by the device's trusted store of certificates.

Calling this method multiple times with the same host name overrides the previously set pins for the host.

More information about the public key pinning can be found in [RFC 7469](https://tools.ietf.org/html/rfc7469).

| Parameters ||
|---|---|
| `hostName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): name of the host to which the public keys should be pinned. A host that consists only of digits and the dot character is treated as invalid. This value cannot be `null`. |
| `pinsSha256` | [MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)\<[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!\>: a set of pins. Each pin is the SHA-256 cryptographic hash of the DER-encoded ASN.1 representation of the Subject Public Key Info (SPKI) of the host's X.509 certificate. Use `https://developer.android.com/reference/kotlin/java/security/cert/Certificate.html#getPublicKey()` and `https://developer.android.com/reference/kotlin/java/security/Key.html#getEncoded()` to obtain DER-encoded ASN.1 representation of the SPKI. Although, the method does not mandate the presence of the backup pin that can be used if the control of the primary private key has been lost, it is highly recommended to supply one. This value cannot be `null`. |
| `includeSubdomains` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): indicates whether the pinning policy should be applied to subdomains of `hostName`. |
| `expirationInstant` | [Instant](https://developer.android.com/reference/kotlin/java/time/Instant.html#): specifies the expiration instant for the pins. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` | the builder to facilitate chaining. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | if the given host name is invalid or `pinsSha256` contains a byte array that does not represent a valid SHA-256 hash. |
| `java.lang.NullPointerException` | if any of the input parameters are `null`. |

### addQuicHint

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)

```
open fun addQuicHint(
    host: String, 
    port: Int, 
    alternatePort: Int
): HttpEngine.Builder
```

Adds hint that `host` supports QUIC. Note that `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setEnableHttpCache(kotlin.Int,%20kotlin.Long)` (`https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#HTTP_CACHE_DISK:kotlin.Int`) is needed to take advantage of 0-RTT connection establishment between sessions.

| Parameters ||
|---|---|
| `host` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): hostname of the server that supports QUIC. This value cannot be `null`. |
| `port` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): host of the server that supports QUIC. |
| `alternatePort` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): alternate port to use for QUIC. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` | the builder to facilitate 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)

```
open fun build(): HttpEngine
```

Build a `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine` using this builder's configuration.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine` | constructed `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine`. This value cannot be `null`. |

### getDefaultUserAgent

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)

```
open fun getDefaultUserAgent(): String
```

Constructs a default User-Agent string including the system build version, model and id, and the HTTP stack version.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | User-Agent string. This value cannot be `null`. |

### setConnectionMigrationOptions

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)

```
open fun setConnectionMigrationOptions(options: ConnectionMigrationOptions): HttpEngine.Builder
```

Configures the behavior of connection migration. For more details, see documentation of `https://developer.android.com/reference/kotlin/android/net/http/ConnectionMigrationOptions` and the individual methods of `https://developer.android.com/reference/kotlin/android/net/http/ConnectionMigrationOptions.Builder`.

Only relevant if `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setEnableQuic(kotlin.Boolean)` is enabled.

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

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` | the builder to facilitate chaining. This value cannot be `null`. |

### setDnsOptions

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)

```
open fun setDnsOptions(options: DnsOptions): HttpEngine.Builder
```

Configures the behavior of hostname lookup. For more details, see documentation of `https://developer.android.com/reference/kotlin/android/net/http/DnsOptions` and the individual methods of `https://developer.android.com/reference/kotlin/android/net/http/DnsOptions.Builder`.

Only relevant if `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setEnableQuic(kotlin.Boolean)` is enabled.

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

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` | the builder to facilitate chaining. This value cannot be `null`. |

### setEnableBrotli

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)

```
open fun setEnableBrotli(value: Boolean): HttpEngine.Builder
```

Sets whether [Brotli](https://tools.ietf.org/html/rfc7932) compression is enabled. If enabled, Brotli will be advertised in Accept-Encoding request headers. Defaults to disabled.

| Parameters ||
|---|---|
| `value` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` to enable Brotli, `false` to disable. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` | the builder to facilitate chaining. This value cannot be `null`. |

### setEnableHttp2

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)

```
open fun setEnableHttp2(value: Boolean): HttpEngine.Builder
```

Sets whether [HTTP/2](https://tools.ietf.org/html/rfc7540) protocol is enabled. Defaults to enabled.

| Parameters ||
|---|---|
| `value` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` to enable HTTP/2, `false` to disable. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` | the builder to facilitate chaining. This value cannot be `null`. |

### setEnableHttpCache

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)

```
open fun setEnableHttpCache(
    cacheMode: Int, 
    maxSize: Long
): HttpEngine.Builder
```

Enables or disables caching of HTTP data and other information like QUIC server information.

| Parameters ||
|---|---|
| `cacheMode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): control location and type of cached data. Must be one of `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#HTTP_CACHE_DISABLED:kotlin.Int`. |
| `maxSize` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): maximum size in bytes used to cache data (advisory and maybe exceeded at times). |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` | the builder to facilitate chaining. This value cannot be `null`. |

### setEnablePublicKeyPinningBypassForLocalTrustAnchors

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)

```
open fun setEnablePublicKeyPinningBypassForLocalTrustAnchors(value: Boolean): HttpEngine.Builder
```

Enables or disables public key pinning bypass for local trust anchors. Disabling the bypass for local trust anchors is highly discouraged since it may prohibit the app from communicating with the pinned hosts. E.g., a user may want to send all traffic through an SSL enabled proxy by changing the device proxy settings and adding the proxy certificate to the list of local trust anchor. Disabling the bypass will most likely prevent the app from sending any traffic to the pinned hosts. For more information see 'How does key pinning interact with local proxies and filters?' at https://www.chromium.org/Home/chromium-security/security-faq

| Parameters ||
|---|---|
| `value` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` to enable the bypass, `false` to disable. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` | the builder to facilitate chaining. This value cannot be `null`. |

### setEnableQuic

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)

```
open fun setEnableQuic(value: Boolean): HttpEngine.Builder
```

Sets whether [QUIC](https://www.chromium.org/quic) protocol is enabled. Defaults to enabled.

| Parameters ||
|---|---|
| `value` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): `true` to enable QUIC, `false` to disable. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` | the builder to facilitate chaining. This value cannot be `null`. |

### setProxyOptions

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

```
open fun setProxyOptions(options: ProxyOptions): HttpEngine.Builder
```

Configures proxying behavior. This affects, in different ways: connections establishment, `https://developer.android.com/reference/kotlin/android/net/http/UrlRequest` and `https://developer.android.com/reference/kotlin/android/net/http/BidirectionalStream`. For more details, refer to the documentation of `https://developer.android.com/reference/kotlin/android/net/http/Proxy`.

This is not to be confused with proxy configuration that have been set up by: the user; or some enterprise profile configuration, or (most likely) some network autoconfiguration (e.g., Web Proxy Auto-Discovery Protocol). This is usually referred to as "system" proxy configuration. If present, respecting the system proxy configuration is often a requirement to obtain local and/or internet connectivity. HttpEngine already handles the system proxy configuration internally.

A proxy configuration defined via this API are refererred to as "app" proxy configuration. App and system proxy configuration are separate and, most importantly, differ. Currently, app and system proxy configurations are mutually exclusive: specifying `https://developer.android.com/reference/kotlin/android/net/http/ProxyOptions` overrides the system proxy configuration, if present. This might cause connectivity problems in some scenarios where a system proxy configuration is present. In such scenarios, users might end up with no internet access, unless `https://developer.android.com/reference/kotlin/android/net/http/ProxyOptions` has been configured with a final, `null`, fallback. Refer to `https://developer.android.com/reference/kotlin/android/net/http/ProxyOptions` documentation.

| Parameters ||
|---|---|
| `options` | [ProxyOptions](https://developer.android.com/reference/kotlin/android/net/http/ProxyOptions): ProxyOptions to be used for `https://developer.android.com/reference/kotlin/android/net/http/UrlRequest`, BiridirectionalStream and connections established by the `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine` created by this builder. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` | the builder to facilitate chaining. |

### setQuicOptions

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)

```
open fun setQuicOptions(options: QuicOptions): HttpEngine.Builder
```

Configures the behavior of the HTTP stack when using QUIC. For more details, see documentation of `https://developer.android.com/reference/kotlin/android/net/http/QuicOptions` and the individual methods of `https://developer.android.com/reference/kotlin/android/net/http/QuicOptions.Builder`.

Only relevant if `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#setEnableQuic(kotlin.Boolean)` is enabled.

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

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` | the builder to facilitate chaining. This value cannot be `null`. |

### setStoragePath

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)

```
open fun setStoragePath(value: String): HttpEngine.Builder
```

Sets directory for HTTP Cache and Cookie Storage. The directory must exist.

**NOTE:** Do not use the same storage directory with more than one `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine` at a time. Access to the storage directory does not support concurrent access by multiple `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine` instances.

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

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` | the builder to facilitate chaining. This value cannot be `null`. |

### setUserAgent

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)

```
open fun setUserAgent(userAgent: String): HttpEngine.Builder
```

Overrides the User-Agent header for all requests. An explicitly set User-Agent header (set using `https://developer.android.com/reference/kotlin/android/net/http/UrlRequest.Builder#addHeader(kotlin.String,%20kotlin.String)`) will override a value set using this function.

| Parameters ||
|---|---|
| `userAgent` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): the User-Agent string to use for all requests. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/http/HttpEngine.Builder#` | the builder to facilitate chaining. This value cannot be `null`. |