[−][src]Trait fastly::response::ResponseExt
An extension trait for HTTP Response
s.
This is used to send a response back downstream to a client that made a request.
Required methods
fn inner_to_body(self) -> Response<Body>
Replace the body of a response with a Body
with the same contents.
fn inner_to_bytes(self) -> Response<Vec<u8>>
Replace the body of a response with the remaining contents of its body.
Note that this will involve copying and buffering the body, and so should only be used for convenience on small response bodies.
fn fastly_metadata(&self) -> Option<&FastlyResponseMetadata>
Get a reference to the Fastly-specific metadata associated with this response.
This method will return None
if this response did not come from an origin server.
fn fastly_metadata_mut(&mut self) -> Option<&mut FastlyResponseMetadata>
Get a mutable reference to the Fastly-specific metadata associated with this response.
This method will return None
if this response did not come from an origin server.
Provided methods
fn send_downstream(self)
Send a response downstream to the client.
fn send_downstream_streaming(self) -> StreamingBodyⓘNotable traits for StreamingBody
impl Write for StreamingBody
Notable traits for StreamingBody
impl Write for StreamingBody
Begin streaming a response downstream, returning a
StreamingBody
that can be appended.
fn backend(&self) -> Option<&Backend>
Get the Backend
that this response came from, if this response came from a backend request.
fn backend_request(&self) -> Option<&Request<()>>
Get the request that this response came from, if this response came from a backend request.
This method will return None
if this response did not come from a backend, or the request
has been taken by backend_request_take()
.
Since the original request's body is consumed by sending it, the body in this request is
empty (represented by ()
).
fn take_backend_request(&mut self) -> Option<Request<()>>
Take the request that this response came from, if this response came from a backend request.
This method will return None
if this response did not come from a backend, or if the
request has been previously taken.
In contrast to RequestExt::backend_request()
, this returns an owned Request<()>
, which
can be used to send another request to a backend.
Since the original request's body is consumed by sending it, the body in this request is
empty (represented by ()
). To add a new body to the request, use Request::map()
, for
example:
let new_body = Body::from("something new"); let new_req = beresp.take_backend_request().unwrap().map(|()| new_body); new_req.send("my_backend")
Implementors
impl ResponseExt for Response<()>
[src]
fn inner_to_body(self) -> Response<Body>
[src]
fn inner_to_bytes(self) -> Response<Vec<u8>>
[src]
fn fastly_metadata(&self) -> Option<&FastlyResponseMetadata>
[src]
fn fastly_metadata_mut(&mut self) -> Option<&mut FastlyResponseMetadata>
[src]
impl ResponseExt for Response<Body>
[src]
fn send_downstream(self)
[src]
Immediately begin sending this response downstream to the client.
fn send_downstream_streaming(self) -> StreamingBodyⓘNotable traits for StreamingBody
impl Write for StreamingBody
[src]
Notable traits for StreamingBody
impl Write for StreamingBody
Immediately begin sending this response downstream to the client, and return a
StreamingBody
that can accept further data to send.