PendingRequest
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 sourcefn 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
poll
View sourcefn poll(self) -> PollResultTry 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 sourceRemove 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 sourceSend 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 sourcefn sent_req(&self) -> &RequestGet 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 sourcefn 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
wait
View sourceBlock 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 sourceBuilder-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
with_set_response_header
View sourceBuilder-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
without_response_header
View sourceBuilder-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