PendingRequest

Structin requestfastly 0.13.1View source
pub struct PendingRequest { /* private fields */ }

A handle to a pending asynchronous request returned by Request::send_async() or Request::send_async_streaming().

A handle can be evaluated using PendingRequest::poll(), PendingRequest::wait(), or 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 is already available.

Methods

append_response_header

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

Append a header to the 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::setaftersend.

Parameters

self: &mut Self
name: impl ToHeaderName
value: impl ToHeaderValue
target: PendingResponseKind
fn poll(self) -> PollResult

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

This function returns immediately with a PollResult; if you want to block until a result is ready, use PendingRequest::wait().

Parameters

self: Self

Returns

remove_response_header

View source
fn remove_response_header(&mut self, name: impl ToHeaderName, target: PendingResponseKind)

Remove a header from the 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::setaftersend.

Parameters

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

send_to_client

View source
fn send_to_client(self) -> Result<(), SendError>

Send the 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 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

sent_req

View source
fn sent_req(&self) -> &Request

Get a reference to the original 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

set_response_header

View source
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 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::setaftersend.

Parameters

self: &mut Self
name: impl ToHeaderName
value: impl ToHeaderValue
target: PendingResponseKind
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().

Parameters

self: Self

Returns

with_response_header

View source
fn with_response_header(self, name: impl ToHeaderName, value: impl ToHeaderValue) -> Self

Builder-style variant of PendingRequest::appendresponseheader.

Note that this defaults to PendingResponseKind::Any. Use PendingRequest::appendresponseheader to change behaviour.

Parameters

self: Self
name: impl ToHeaderName
value: impl ToHeaderValue

Returns

Self

with_set_response_header

View source
fn with_set_response_header(self, name: impl ToHeaderName, value: impl ToHeaderValue) -> Self

Builder-style variant of PendingRequest::setresponseheader.

Note that this defaults to PendingResponseKind::Any. Use PendingRequest::setresponseheader to change behaviour.

Parameters

self: Self
name: impl ToHeaderName
value: impl ToHeaderValue

Returns

Self

without_response_header

View source
fn without_response_header(self, name: impl ToHeaderName) -> Self

Builder-style variant of PendingRequest::removeresponseheader.

Note that this defaults to PendingResponseKind::Any. Use PendingRequest::removeresponseheader to change behaviour.

Parameters

self: Self
name: impl ToHeaderName

Returns

Self

Trait implementations

impl HandlerResult for PendingRequest

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

Parameters

self: Self

Returns

Result<(), Self::Error>

Auto trait implementations

Blanket implementations