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: [Nested Classes](https://developer.android.com/reference/android/net/http/Proxy#nestedclasses) \| [Constants](https://developer.android.com/reference/android/net/http/Proxy#constants) \| [Methods](https://developer.android.com/reference/android/net/http/Proxy#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/http/Proxy#inhmethods)

# Proxy

*** ** * ** ***


`
public

final

class
Proxy
`


`

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


`

`


`

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

<br />

*** ** * ** ***

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

How HTTP requests are sent via proxies depends on a variety of factors. For example: the type
of proxy being used, the HTTP version being used, whether the request is being sent to a
destination with an http or https URI scheme. Additionally, whether a tunnel through the proxy is
established, or not, also depends on these factors.

## Summary

| ### Nested classes ||
|---|---|
| ` interface` | `https://developer.android.com/reference/android/net/http/Proxy.HttpConnectCallback` Controls tunnels established via HTTP CONNECT. |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/net/http/Proxy#SCHEME_HTTP` Establish a plaintext connection to the proxy itself. |
| `int` | `https://developer.android.com/reference/android/net/http/Proxy#SCHEME_HTTPS` Establish a secure connection to the proxy itself. |

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/android/net/http/Proxy` | ` https://developer.android.com/reference/android/net/http/Proxy#createHttpProxy(int,%20java.lang.String,%20int,%20java.util.concurrent.Executor,%20android.net.http.Proxy.HttpConnectCallback)(int scheme, https://developer.android.com/reference/java/lang/String host, int port, https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/android/net/http/Proxy.HttpConnectCallback callback) ` Constructs an 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

### SCHEME_HTTP

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 SCHEME_HTTP
```

Establish a plaintext connection to the proxy itself.

<br />

Constant Value:

0
(0x00000000)


### SCHEME_HTTPS

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 SCHEME_HTTPS
```

Establish a secure connection to the proxy itself.

<br />

Constant Value:

1
(0x00000001)


## Public methods

### createHttpProxy

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 Proxy createHttpProxy (int scheme, 
                String host, 
                int port, 
                Executor executor, 
                Proxy.HttpConnectCallback callback)
```

Constructs an HTTP proxy.

When sending HTTP requests via an HTTP proxy, whether `callback` is called, or not,
depends on the URI scheme of the destination:

- For destinations with an https URI scheme, HttpEngine establishes a tunnel through the proxy. The tunnel is established via an HTTP CONNECT request. In this case {code callback} will be called to control the HTTP CONNECT request used to establish the tunnel.
- For destinations with an http URI scheme, HttpEngine sends an HTTP request, containing the entire URI of the destination, to the proxy. In this case `callback` will not be called.

<br />

<br />

| Parameters ||
|---|---|
| `scheme` | `int`: `https://developer.android.com/` that, alongside `host` and `port`, identifies this proxy. Value is one of the following: - `https://developer.android.com/reference/android/net/http/Proxy#SCHEME_HTTP` - `https://developer.android.com/reference/android/net/http/Proxy#SCHEME_HTTPS` |
| `host` | `String`: Non-empty host that, alongside `scheme` and `port`, identifies this proxy. This value cannot be `null`. <br /> |
| `port` | `int`: Port that, alongside `scheme` and `host`, identifies this proxy. Its value must be within \[0, 65535\]. Value is between 0 and 65535 inclusive <br /> |
| `executor` | `Executor`: Executor where `callback` will be invoked. This value cannot be `null`. <br /> |
| `callback` | `Proxy.HttpConnectCallback`: Callback that allows interacting with the HTTP CONNECT request, and its response, that HttpEngine sends to establish tunnels through the proxy. This value cannot be `null`. <br /> |

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