Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [S Extensions 22](https://developer.android.com/sdkExtensions) Summary: [Constants](https://developer.android.com/reference/android/net/http/ProxyOptions#constants) \| [Methods](https://developer.android.com/reference/android/net/http/ProxyOptions#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/http/ProxyOptions#inhmethods)

# ProxyOptions

*** ** * ** ***


`
public

final

class
ProxyOptions
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.http.ProxyOptions |

<br />

*** ** * ** ***

Defines a proxy configuration that can be used by `https://developer.android.com/reference/android/net/http/HttpEngine`.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/net/http/ProxyOptions#ALL_PROXIES_FAILED_BEHAVIOR_ALLOW_DIRECT` Allows direct, non-proxied, traffic. |
| `int` | `https://developer.android.com/reference/android/net/http/ProxyOptions#ALL_PROXIES_FAILED_BEHAVIOR_DISALLOW_DIRECT` Disallows direct traffic. |

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/android/net/http/ProxyOptions` | ` https://developer.android.com/reference/android/net/http/ProxyOptions#fromProxyList(java.util.List<android.net.http.Proxy>,%20int)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/net/http/Proxy> proxyList, int allProxiesFailedBehavior) ` Constructs a proxy configuration out of a list of `https://developer.android.com/reference/android/net/http/Proxy`. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Constants

### ALL_PROXIES_FAILED_BEHAVIOR_ALLOW_DIRECT

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

```
public static final int ALL_PROXIES_FAILED_BEHAVIOR_ALLOW_DIRECT
```

Allows direct, non-proxied, traffic.

This defines a fail-open behavior: if all proxies in a `https://developer.android.com/reference/android/net/http/ProxyOptions` have failed,
HttpEngine will fall back onto non-proxied connections.

<br />

Constant Value:

1
(0x00000001)


### ALL_PROXIES_FAILED_BEHAVIOR_DISALLOW_DIRECT

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

```
public static final int ALL_PROXIES_FAILED_BEHAVIOR_DISALLOW_DIRECT
```

Disallows direct traffic.

This defines a fail-closed behavior: if all proxies in a `https://developer.android.com/reference/android/net/http/ProxyOptions` have failed,
HttpEngine won't fall back onto non-proxied connections.

<br />

Constant Value:

0
(0x00000000)


## Public methods

### fromProxyList

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

```
public static ProxyOptions fromProxyList (List<Proxy> proxyList, 
                int allProxiesFailedBehavior)
```

Constructs a proxy configuration out of a list of `https://developer.android.com/reference/android/net/http/Proxy`.

Proxies in the list will be used in order. Proxy in position N+1 will be used only if
HttpEngine 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/reference/android/net/http/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.

<br />

| Parameters ||
|---|---|
| `proxyList` | `List`: The list of `https://developer.android.com/reference/android/net/http/Proxy` that defines this configuration. This value cannot be `null`. <br /> |
| `allProxiesFailedBehavior` | `int`: How HttpEngine must behave after it has failed to use all proxies in `proxyList`. Value is one of the following: - `https://developer.android.com/reference/android/net/http/ProxyOptions#ALL_PROXIES_FAILED_BEHAVIOR_DISALLOW_DIRECT` - `https://developer.android.com/reference/android/net/http/ProxyOptions#ALL_PROXIES_FAILED_BEHAVIOR_ALLOW_DIRECT` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/http/ProxyOptions` | This value cannot be `null`. <br /> |

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