# Proxy


```
class Proxy
```

<br />

*** ** * ** ***

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

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 types |
|---|
| `abstract class https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy.HttpConnectCallback` Controls tunnels established via HTTP CONNECT. |
| `@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/Proxy.HttpConnectCallback.OnResponseReceivedAction` Actions that can be performed in response to `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy.HttpConnectCallback#onResponseReceived(java.util.List<android.util.Pair<java.lang.String,java.lang.String>>,int)` being called. |
| `abstract class https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy.HttpConnectCallback.Request : https://developer.android.com/reference/java/lang/AutoCloseable.html` Represents an HTTP CONNECT request being sent to the proxy server. |
| `@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/Proxy.Scheme` Schemes supported when defining a proxy. |

| ### 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/Proxy#SCHEME_HTTP() = 0` Establish a plaintext connection to the proxy itself. |
| `const https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy#SCHEME_HTTPS() = 1` Establish a secure connection to the proxy itself. |

| ### Public functions |
|---|---|
| `java-static 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/Proxy#createHttpProxy(int,java.lang.String,int,java.util.concurrent.Executor,org.chromium.net.Proxy.HttpConnectCallback)( @https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy.Scheme scheme: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, host: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, port: @https://developer.android.com/reference/androidx/annotation/IntRange.html(from = 0, to = 65535) https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, callback: https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy.HttpConnectCallback )` Constructs an HTTP proxy. |

## Constants

### SCHEME_HTTP

```
const val SCHEME_HTTP = 0: Int
```

Establish a plaintext connection to the proxy itself.

### SCHEME_HTTPS

```
const val SCHEME_HTTPS = 1: Int
```

Establish a secure connection to the proxy itself.

## Public functions

### createHttpProxy

```
java-static fun createHttpProxy(
    @Proxy.Scheme scheme: Int,
    host: String,
    port: @IntRange(from = 0, to = 65535) Int,
    executor: Executor,
    callback: Proxy.HttpConnectCallback
): Proxy
```

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, CronetEngine establishes a tunnel through the proxy. The tunnel is established via an HTTP CONNECT request. In this case `
  callback` will be called to control the HTTP CONNECT request used to establish the tunnel.
- For destinations with an http URI scheme, CronetEngine sends an HTTP request, containing the entire URI of the destination, to the proxy. In this case `
  callback` will not be called.

| Parameters |
|---|---|
| `@https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy.Scheme scheme: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | `https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy.Scheme` that, alongside `host` and `port`, identifies this proxy. |
| `host: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | Non-empty host that, alongside `scheme` and `port`, identifies this proxy. |
| `port: @https://developer.android.com/reference/androidx/annotation/IntRange.html(from = 0, to = 65535) https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | Port that, alongside `scheme` and `host`, identifies this proxy. Its value must be within \[0, 65535\]. |
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | Executor where `callback` will be invoked. |
| `callback: https://developer.android.com/develop/connectivity/cronet/reference/kotlin/org/chromium/net/Proxy.HttpConnectCallback` | Callback that allows interacting with the HTTP CONNECT request, and its response, that CronetEngine sends to establish tunnels through the proxy. |