[][src]Trait fastly::response::ResponseExt

pub trait ResponseExt: Sized {
    pub fn inner_to_body(self) -> Response<Body>;
pub fn inner_to_bytes(self) -> Response<Vec<u8>>;
pub fn fastly_metadata(&self) -> Option<&FastlyResponseMetadata>;
pub fn fastly_metadata_mut(&mut self) -> Option<&mut FastlyResponseMetadata>; pub fn send_downstream(self) { ... }
pub fn send_downstream_streaming(self) -> StreamingBody

Notable traits for StreamingBody

impl Write for StreamingBody
{ ... }
pub fn backend(&self) -> Option<&Backend> { ... }
pub fn backend_request(&self) -> Option<&Request<()>> { ... }
pub fn take_backend_request(&mut self) -> Option<Request<()>> { ... } }

An extension trait for HTTP Responses.

This is used to send a response back downstream to a client that made a request.

Required methods

pub fn inner_to_body(self) -> Response<Body>[src]

Replace the body of a response with a Body with the same contents.

pub fn inner_to_bytes(self) -> Response<Vec<u8>>[src]

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.

pub fn fastly_metadata(&self) -> Option<&FastlyResponseMetadata>[src]

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.

pub fn fastly_metadata_mut(&mut self) -> Option<&mut FastlyResponseMetadata>[src]

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.

Loading content...

Provided methods

pub fn send_downstream(self)[src]

Send a response downstream to the client.

pub fn send_downstream_streaming(self) -> StreamingBody

Notable traits for StreamingBody

impl Write for StreamingBody
[src]

Begin streaming a response downstream, returning a StreamingBody that can be appended.

pub fn backend(&self) -> Option<&Backend>[src]

Get the Backend that this response came from, if this response came from a backend request.

pub fn backend_request(&self) -> Option<&Request<()>>[src]

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 ()).

pub fn take_backend_request(&mut self) -> Option<Request<()>>[src]

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")
Loading content...

Implementors

impl ResponseExt for Response<&str>[src]

impl ResponseExt for Response<&[u8]>[src]

impl ResponseExt for Response<()>[src]

impl ResponseExt for Response<Body>[src]

pub fn send_downstream(self)[src]

Immediately begin sending this response downstream to the client.

pub fn send_downstream_streaming(self) -> StreamingBody

Notable traits for StreamingBody

impl Write for StreamingBody
[src]

Immediately begin sending this response downstream to the client, and return a StreamingBody that can accept further data to send.

impl ResponseExt for Response<String>[src]

impl ResponseExt for Response<Vec<u8>>[src]

Loading content...