pub trait ResponseExtwhere
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§
Sourcefn new_status_reason<T>(status: u16, reason: T) -> Self
fn new_status_reason<T>(status: u16, reason: T) -> Self
Creates a new HTTP response with the given status code and reason and sets an empty body
Sourcefn new_200_ok() -> Self
fn new_200_ok() -> Self
Creates a new 200 OK HTTP response with an empty body
Sourcefn new_307_temporaryredirect<T>(location: T) -> Self
fn new_307_temporaryredirect<T>(location: T) -> Self
Creates a new 307 Temporary Redirect HTTP response with an empty body and the Location-header field set to the
given location
Sourcefn new_400_badrequest() -> Self
fn new_400_badrequest() -> Self
Creates a new 400 Bad Request HTTP response with an empty body
Creates a new 401 Unauthorized HTTP response with an empty body and the WWW-Authenticate-header field set to
the given requirement
Sourcefn new_403_forbidden() -> Self
fn new_403_forbidden() -> Self
Creates a new 403 Forbidden HTTP response with an empty body
Sourcefn new_404_notfound() -> Self
fn new_404_notfound() -> Self
Creates a new 404 Not Found HTTP response with an empty body
Sourcefn new_405_methodnotallowed() -> Self
fn new_405_methodnotallowed() -> Self
Creates a new 405 Method Not Allowed HTTP response with an empty body
Sourcefn new_413_payloadtoolarge() -> Self
fn new_413_payloadtoolarge() -> Self
Creates a new 413 Payload Too Large HTTP response with an empty body
Sourcefn new_416_rangenotsatisfiable() -> Self
fn new_416_rangenotsatisfiable() -> Self
Creates a new 416 Range Not Satisfiable HTTP response with an empty body
Sourcefn new_500_internalservererror() -> Self
fn new_500_internalservererror() -> Self
Creates a new 500 Internal Server Error HTTP response with an empty body
Sourcefn set_field<K, V>(&mut self, key: K, value: V)
fn set_field<K, V>(&mut self, key: K, value: V)
Sets the field with the given name (performs an ASCII-case-insensitve comparison for replacement)
Sourcefn set_content_type<T>(&mut self, type_: T)
fn set_content_type<T>(&mut self, type_: T)
Sets the body content type
Sourcefn set_content_length(&mut self, len: u64)
fn set_content_length(&mut self, len: u64)
Sets the body content length
Sourcefn set_connection_close(&mut self)
fn set_connection_close(&mut self)
Sets the connection header to Close
Sourcefn set_body_data<T>(&mut self, data: T)
fn set_body_data<T>(&mut self, data: T)
Sets the given data as body content and updates the Content-Length header accordingly
Sourcefn set_body_file<T>(&mut self, file: T) -> Result<(), Error>
fn set_body_file<T>(&mut self, file: T) -> Result<(), Error>
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.
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.