# Request

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/android/net/http/Proxy.HttpConnectCallback.Request "View this page in Java")

```
class Request : AutoCloseable
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [android.net.http.Proxy.HttpConnectCallback.Request](https://developer.android.com/reference/kotlin/android/net/http/Proxy.HttpConnectCallback.Request#) |

Represents an HTTP CONNECT request being sent to the proxy server.

All methods may be called synchronously or asynchronously, on any thread.

## Summary

| Public methods ||
|---|---|
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/net/http/Proxy.HttpConnectCallback.Request#close()()` Releases all resources associated with the tunnel establishment request. |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | `https://developer.android.com/reference/kotlin/android/net/http/Proxy.HttpConnectCallback.Request#proceed(kotlin.collections.MutableList)(extraHeaders: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://developer.android.com/reference/kotlin/android/util/Pair.html#<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html!>!>)` Allows the tunnel establishment request to proceed, adding the extra headers to the underlying HTTP CONNECT request. |

## Public methods

### close

```
fun close(): Unit
```

Releases all resources associated with the tunnel establishment request.

If this method is called after `https://developer.android.com/reference/kotlin/android/net/http/Proxy.HttpConnectCallback.Request#proceed(kotlin.collections.MutableList)`, this will have no effect on the tunnel establishment request and the underlying HTTP CONNECT, they will keep proceeding.

If this method is called before `https://developer.android.com/reference/kotlin/android/net/http/Proxy.HttpConnectCallback.Request#proceed(kotlin.collections.MutableList)`, the tunnel establishment request and the underlying HTTP CONNECT request will be canceled.

When a tunnel establishment request is canceled, HttpEngine will interpret it as a failure to use the associated `https://developer.android.com/reference/kotlin/android/net/http/Proxy`. HttpEngine will then try the next `https://developer.android.com/reference/kotlin/android/net/http/Proxy` in the list passed to `https://developer.android.com/reference/kotlin/android/net/http/ProxyOptions` (refer to that class documentation for more info).

| Exceptions ||
|---|---|
| `java.lang.Exception` | if this resource cannot be closed |

### proceed

```
fun proceed(extraHeaders: MutableList<Pair<String!, String!>!>): Unit
```

Allows the tunnel establishment request to proceed, adding the extra headers to the underlying HTTP CONNECT request.

| Parameters ||
|---|---|
| `extraHeaders` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[Pair](https://developer.android.com/reference/kotlin/android/util/Pair.html#)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!, [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>!\>: A list of RFC 2616-compliant headers to be added to HTTP CONNECT request directed to the proxy server. This list can be empty, in which case no headers will be added. Note: these headers won't be added to the HTTP requests that will go through the tunnel once it is established. This value cannot be `null`. |

| Exceptions ||
|---|---|
| `java.lang.IllegalArgumentException` | If any of the headers is not RFC 2616-compliant. |
| `java.lang.IllegalStateException` | If this method is called multiple times, or after `https://developer.android.com/reference/kotlin/android/net/http/Proxy.HttpConnectCallback.Request#close()` has been called. |