CServerResponse

Type Alias CServerResponse 

Source
pub type CServerResponse = Response;
Expand description

Wrapper over the rouille::Response struct to prevent name collisions.

Aliased Type§

pub struct CServerResponse {
    pub status_code: u16,
    pub headers: Vec<(Cow<'static, str>, Cow<'static, str>)>,
    pub data: ResponseBody,
    pub upgrade: Option<Box<dyn Upgrade + Send>>,
}

Fields§

§status_code: u16

The status code to return to the user.

§headers: Vec<(Cow<'static, str>, Cow<'static, str>)>

List of headers to be returned in the response.

The value of the following headers will be ignored from this list, even if present:

  • Accept-Ranges
  • Connection
  • Content-Length
  • Content-Range
  • Trailer
  • Transfer-Encoding

Additionally, the Upgrade header is ignored as well unless the upgrade field of the Response is set to something.

The reason for this is that these headers are too low-level and are directly handled by the underlying HTTP response system.

The value of Content-Length is automatically determined by the ResponseBody object of the data member.

If you want to send back Connection: upgrade, you should set the value of the upgrade field to something.

§data: ResponseBody

An opaque type that contains the body of the response.

§upgrade: Option<Box<dyn Upgrade + Send>>

If set, rouille will give ownership of the client socket to the Upgrade object.

In all circumstances, the value of the Connection header is managed by the framework and cannot be customized. If this value is set, the response will automatically contain Connection: Upgrade.