Struct http_cache::HttpResponse
source · pub struct HttpResponse {
pub body: Vec<u8>,
pub headers: HashMap<String, String>,
pub status: u16,
pub url: Url,
pub version: HttpVersion,
}Expand description
A basic generic type that represents an HTTP response
Fields§
§body: Vec<u8>HTTP response body
headers: HashMap<String, String>HTTP response headers
status: u16HTTP response status code
url: UrlHTTP response url
version: HttpVersionHTTP response version
Implementations§
source§impl HttpResponse
impl HttpResponse
sourcepub fn warning_code(&self) -> Option<usize>
pub fn warning_code(&self) -> Option<usize>
Returns the status code of the warning header if present
sourcepub fn add_warning(&mut self, url: &Url, code: usize, message: &str)
pub fn add_warning(&mut self, url: &Url, code: usize, message: &str)
Adds a warning header to a response
sourcepub fn remove_warning(&mut self)
pub fn remove_warning(&mut self)
Removes a warning header from a response
sourcepub fn update_headers(&mut self, parts: &Parts) -> Result<()>
pub fn update_headers(&mut self, parts: &Parts) -> Result<()>
Update the headers from http::response::Parts
sourcepub fn must_revalidate(&self) -> bool
pub fn must_revalidate(&self) -> bool
Checks if the Cache-Control header contains the must-revalidate directive
sourcepub fn cache_status(&mut self, hit_or_miss: HitOrMiss)
pub fn cache_status(&mut self, hit_or_miss: HitOrMiss)
Adds the custom x-cache header to the response
sourcepub fn cache_lookup_status(&mut self, hit_or_miss: HitOrMiss)
pub fn cache_lookup_status(&mut self, hit_or_miss: HitOrMiss)
Adds the custom x-cache-lookup header to the response
Trait Implementations§
source§impl Clone for HttpResponse
impl Clone for HttpResponse
source§fn clone(&self) -> HttpResponse
fn clone(&self) -> HttpResponse
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for HttpResponse
impl Debug for HttpResponse
source§impl<'de> Deserialize<'de> for HttpResponse
impl<'de> Deserialize<'de> for HttpResponse
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more