---
title: PendingRequest
summary: A handle to a pending asynchronous request returned by Request::sendasync() or Request::sendasync_streaming().
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/
---

**Kind:** Struct  
**Module:** [request](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/)  
**Package:** fastly 0.13.1  
**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request/pending.rs#26

```rust
pub struct PendingRequest { /* private fields */ }
```

A handle to a pending asynchronous request returned by [`Request::send_async()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-send_async) or
[`Request::send_async_streaming()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-send_async_streaming).

A handle can be evaluated using [`PendingRequest::poll()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/#method-poll), [`PendingRequest::wait()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/#method-wait), or
[`select`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/fn.select/). It can also be discarded if the request was sent for effects it might have, and the
response is unimportant.

Internally, pending requests may advance through multiple asynchronous stages. A readiness event
may only indicate that the request can advance to its next stage, not that a final [`Response`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/)
is already available.

## Methods

### append_response_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request/pending.rs#87

```rust
fn append_response_header(&mut self, name: impl ToHeaderName, value: impl ToHeaderValue, target: PendingResponseKind)
```

Append a header to the [Response](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/) once it is ready.

Note that when caching this is applied after the cache has been updated. If you
want to change the headers that are inserted into the cache, then use
[Request::set_after_send](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_after_send).

**Parameters**

- `self`: `&mut Self`
- `name`: `impl ToHeaderName`
- `value`: `impl ToHeaderValue`
- `target`: `PendingResponseKind`

### poll

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request/pending.rs#169

```rust
fn poll(self) -> PollResult
```

Try to get the result of a pending request without blocking.

This function returns immediately with a [`PollResult`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/enum.PollResult/); if you want to block until a result
is ready, use [`PendingRequest::wait()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/#method-wait).

**Parameters**

- `self`: `Self`

**Returns**

`PollResult`

### remove_response_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request/pending.rs#116

```rust
fn remove_response_header(&mut self, name: impl ToHeaderName, target: PendingResponseKind)
```

Remove a header from the [Response](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/) once it is available.

Note that when caching this is applied after the cache has been updated. If you
want to change the headers that are inserted into the cache, then use
[Request::set_after_send](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_after_send).

**Parameters**

- `self`: `&mut Self`
- `name`: `impl ToHeaderName`
- `target`: `PendingResponseKind`

### send_to_client

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request/pending.rs#161

```rust
fn send_to_client(self) -> Result<(), SendError>
```

Send the [Response](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/) to the client as soon as any cache updates are resolved.

If this is a direct pass or hit-for-pass request, and no cache insertions are
necessary, then the [PendingRequest](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/) will continue in the background allowing
the sandbox to terminate early so that its resources may be freed up for other
incoming requests.

**Parameters**

- `self`: `Self`

**Returns**

`Result<(), SendError>`

### sent_req

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request/pending.rs#192

```rust
fn sent_req(&self) -> &Request
```

Get a reference to the original [`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) associated with this pending request.

Note that the request's original body is already sending, so the returned request does not
have a body.

**Parameters**

- `self`: `&Self`

**Returns**

`&Request`

### set_response_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request/pending.rs#102

```rust
fn set_response_header(&mut self, name: impl ToHeaderName, value: impl ToHeaderValue, target: PendingResponseKind)
```

Insert a header (replacing any existing values of the same name) on the [Response](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/)
once it is ready.

Note that when caching this is applied after the cache has been updated. If you
want to change the headers that are inserted into the cache, then use
[Request::set_after_send](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_after_send).

**Parameters**

- `self`: `&mut Self`
- `name`: `impl ToHeaderName`
- `value`: `impl ToHeaderValue`
- `target`: `PendingResponseKind`

### wait

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request/pending.rs#181

```rust
fn wait(self) -> Result<Response, SendError>
```

Block until the result of a pending request is ready.

If you want check whether the result is ready without blocking, use
[`PendingRequest::poll()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/#method-poll).

**Parameters**

- `self`: `Self`

**Returns**

`Result<Response, SendError>`

### with_response_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request/pending.rs#124

```rust
fn with_response_header(self, name: impl ToHeaderName, value: impl ToHeaderValue) -> Self
```

Builder-style variant of [PendingRequest::append_response_header](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/#method-append_response_header).

Note that this defaults to [PendingResponseKind::Any](https://docs.rs/fastly_sys/latest/fastly_sys/fastly_http_req/enum.PendingResponseKind.html#variant.Any). Use
[PendingRequest::append_response_header](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/#method-append_response_header) to change behaviour.

**Parameters**

- `self`: `Self`
- `name`: `impl ToHeaderName`
- `value`: `impl ToHeaderValue`

**Returns**

`Self`

### with_set_response_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request/pending.rs#137

```rust
fn with_set_response_header(self, name: impl ToHeaderName, value: impl ToHeaderValue) -> Self
```

Builder-style variant of [PendingRequest::set_response_header](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/#method-set_response_header).

Note that this defaults to [PendingResponseKind::Any](https://docs.rs/fastly_sys/latest/fastly_sys/fastly_http_req/enum.PendingResponseKind.html#variant.Any). Use
[PendingRequest::set_response_header](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/#method-set_response_header) to change behaviour.

**Parameters**

- `self`: `Self`
- `name`: `impl ToHeaderName`
- `value`: `impl ToHeaderValue`

**Returns**

`Self`

### without_response_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request/pending.rs#150

```rust
fn without_response_header(self, name: impl ToHeaderName) -> Self
```

Builder-style variant of [PendingRequest::remove_response_header](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/#method-remove_response_header).

Note that this defaults to [PendingResponseKind::Any](https://docs.rs/fastly_sys/latest/fastly_sys/fastly_http_req/enum.PendingResponseKind.html#variant.Any). Use
[PendingRequest::remove_response_header](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/#method-remove_response_header) to change behaviour.

**Parameters**

- `self`: `Self`
- `name`: `impl ToHeaderName`

**Returns**

`Self`

## Trait implementations

### impl HandlerResult for PendingRequest

#### send

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/serve.rs#103

```rust
fn send(self) -> Result<(), Self::Error>
```

**Parameters**

- `self`: `Self`

**Returns**

`Result<(), Self::Error>`

## Auto trait implementations

- `Freeze`
- `RefUnwindSafe`
- `Send`
- `Sync`
- `Unpin`
- `UnsafeUnpin`
- `UnwindSafe`

## Blanket implementations

- `Any`
- `Borrow<T>`
- `BorrowMut<T>`
- `Downcast`
- `ErasedDestructor`
- `From<T>`
- `Into<U>`
- `IntoEither`
- `Same`
- `TryFrom<U>`
- `TryInto<U>`
