Proxy
class Proxy
| kotlin.Any | |
| ↳ | android.net.http.Proxy |
Represents a proxy that can be used by 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 | |
|---|---|
| abstract |
Controls tunnels established via HTTP CONNECT. |
| Constants | |
|---|---|
| static Int |
Establish a plaintext connection to the proxy itself. |
| static Int |
Establish a secure connection to the proxy itself. |
| Public methods | |
|---|---|
| static Proxy |
createHttpProxy(scheme: Int, host: String, port: Int, executor: Executor, callback: Proxy.HttpConnectCallback)Constructs an HTTP proxy. |
Constants
SCHEME_HTTP
static val SCHEME_HTTP: Int
Establish a plaintext connection to the proxy itself.
Value: 0SCHEME_HTTPS
static val SCHEME_HTTPS: Int
Establish a secure connection to the proxy itself.
Value: 1Public methods
createHttpProxy
static fun createHttpProxy(
scheme: Int,
host: String,
port: 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, 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
callbackwill not be called.
| Parameters | |
|---|---|
scheme |
Int: android.net.http.Proxy.Scheme that, alongside host and port, identifies this proxy. Value is one of the following: |
host |
String: Non-empty host that, alongside scheme and port, identifies this proxy. This value cannot be null. |
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 |
executor |
Executor: Executor where callback will be invoked. This value cannot be null. |
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. |
| Return | |
|---|---|
Proxy |
This value cannot be null. |