# ProxyOptions


```
class ProxyOptions
```

<br />

*** ** * ** ***

Defines a proxy configuration that can be used by `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/CronetEngine`.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/androidx/annotation/IntDef.html(value = ) annotation https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/ProxyOptions.AllProxiesFailedBehavior` Defines behavior after all proxies in a `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/ProxyOptions` have failed. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/ProxyOptions#ALL_PROXIES_FAILED_BEHAVIOR_ALLOW_DIRECT() = 1` Allows direct, non-proxied, traffic. |
| `const https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/ProxyOptions#ALL_PROXIES_FAILED_BEHAVIOR_DISALLOW_DIRECT() = 0` Disallows direct traffic. |

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/ProxyOptions` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/ProxyOptions#fromProxyList(java.util.List<org.chromium.net.Proxy>,int)( proxyList: (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy!>, @https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/ProxyOptions.AllProxiesFailedBehavior allProxiesFailedBehavior: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html )` Constructs a proxy configuration out of a list of `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy`. |

## Constants

### ALL_PROXIES_FAILED_BEHAVIOR_ALLOW_DIRECT

```
const val ALL_PROXIES_FAILED_BEHAVIOR_ALLOW_DIRECT = 1: Int
```

Allows direct, non-proxied, traffic.

This defines a fail-open behavior: if all proxies in a `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/ProxyOptions` have failed, CronetEngine will fall back onto non-proxied connections.

### ALL_PROXIES_FAILED_BEHAVIOR_DISALLOW_DIRECT

```
const val ALL_PROXIES_FAILED_BEHAVIOR_DISALLOW_DIRECT = 0: Int
```

Disallows direct traffic.

This defines a fail-closed behavior: if all proxies in a `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/ProxyOptions` have failed, CronetEngine won't fall back onto non-proxied connections.

## Public functions

### fromProxyList

```
java-static fun fromProxyList(
    proxyList: (Mutable)List<Proxy!>,
    @ProxyOptions.AllProxiesFailedBehavior allProxiesFailedBehavior: Int
): ProxyOptions
```

Constructs a proxy configuration out of a list of `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy`.

Proxies in the list will be used in order. Proxy in position N+1 will be used only if CronetEngine failed to use proxy in position N. If proxy in position N fails, for any reason (including tunnel closures triggered via `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy.HttpConnectCallback`), but proxy in position N+1 succeeds, proxies in position N will be temporarily deprioritized. While a proxy is deprioritized it will be used only as a last resort.

| Parameters |
|---|---|
| `proxyList: (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy!>` | The list of `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy` that defines this configuration. |
| `@https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/ProxyOptions.AllProxiesFailedBehavior allProxiesFailedBehavior: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | How CronetEngine must behave after it has failed to use all proxies in `proxyList`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If the proxy list is empty, or any element is `null`. |