ResponseExt

Trait ResponseExt 

Source
pub trait ResponseExt
where Self: Sized,
{
Show 19 methods // Required methods fn new_status_reason<T>(status: u16, reason: T) -> Self where T: Into<Data>; fn new_200_ok() -> Self; fn new_307_temporaryredirect<T>(location: T) -> Self where T: Into<Data>; fn new_400_badrequest() -> Self; fn new_401_unauthorized<T>(requirement: T) -> Self where T: Into<Data>; fn new_403_forbidden() -> Self; fn new_404_notfound() -> Self; fn new_405_methodnotallowed() -> Self; fn new_413_payloadtoolarge() -> Self; fn new_416_rangenotsatisfiable() -> Self; fn new_500_internalservererror() -> Self; fn set_field<K, V>(&mut self, key: K, value: V) where K: Into<Data>, V: Into<Data>; fn set_content_type<T>(&mut self, type_: T) where T: Into<Data>; fn set_content_length(&mut self, len: u64); fn set_connection_close(&mut self); fn content_length(&self) -> Result<Option<u64>, Error>; fn set_body_data<T>(&mut self, data: T) where T: Into<Data>; fn set_body_file<T>(&mut self, file: T) -> Result<(), Error> where T: Into<File>; fn make_head(&mut self);
}
Expand description

Some HTTP response extensions

Required Methods§

Source

fn new_status_reason<T>(status: u16, reason: T) -> Self
where T: Into<Data>,

Creates a new HTTP response with the given status code and reason and sets an empty body

Source

fn new_200_ok() -> Self

Creates a new 200 OK HTTP response with an empty body

Source

fn new_307_temporaryredirect<T>(location: T) -> Self
where T: Into<Data>,

Creates a new 307 Temporary Redirect HTTP response with an empty body and the Location-header field set to the given location

Source

fn new_400_badrequest() -> Self

Creates a new 400 Bad Request HTTP response with an empty body

Source

fn new_401_unauthorized<T>(requirement: T) -> Self
where T: Into<Data>,

Creates a new 401 Unauthorized HTTP response with an empty body and the WWW-Authenticate-header field set to the given requirement

Source

fn new_403_forbidden() -> Self

Creates a new 403 Forbidden HTTP response with an empty body

Source

fn new_404_notfound() -> Self

Creates a new 404 Not Found HTTP response with an empty body

Source

fn new_405_methodnotallowed() -> Self

Creates a new 405 Method Not Allowed HTTP response with an empty body

Source

fn new_413_payloadtoolarge() -> Self

Creates a new 413 Payload Too Large HTTP response with an empty body

Source

fn new_416_rangenotsatisfiable() -> Self

Creates a new 416 Range Not Satisfiable HTTP response with an empty body

Source

fn new_500_internalservererror() -> Self

Creates a new 500 Internal Server Error HTTP response with an empty body

Source

fn set_field<K, V>(&mut self, key: K, value: V)
where K: Into<Data>, V: Into<Data>,

Sets the field with the given name (performs an ASCII-case-insensitve comparison for replacement)

Source

fn set_content_type<T>(&mut self, type_: T)
where T: Into<Data>,

Sets the body content type

Source

fn set_content_length(&mut self, len: u64)

Sets the body content length

Source

fn set_connection_close(&mut self)

Sets the connection header to Close

Source

fn content_length(&self) -> Result<Option<u64>, Error>

Returns the content length if it is set

Source

fn set_body_data<T>(&mut self, data: T)
where T: Into<Data>,

Sets the given data as body content and updates the Content-Length header accordingly

Source

fn set_body_file<T>(&mut self, file: T) -> Result<(), Error>
where T: Into<File>,

Sets the given file as body content and updates the Content-Length header accordingly

§Note

Please note that this function also respects the file’s current seek offset; so if you are at offset 7 out of 15, the content length is set to 8.

Source

fn make_head(&mut self)

Turns the current GET-response into a HEAD-response by discarding the body without modifying content length etc.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<const HEADER_SIZE_MAX: usize> ResponseExt for Response<HEADER_SIZE_MAX>