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: u16
HTTP response status code
url: Url
HTTP response url
version: HttpVersion
HTTP response version
Implementations
sourceimpl 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
sourceimpl Clone for HttpResponse
impl Clone for HttpResponse
sourcefn clone(&self) -> HttpResponse
fn clone(&self) -> HttpResponse
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for HttpResponse
impl Debug for HttpResponse
sourceimpl<'de> Deserialize<'de> for HttpResponse
impl<'de> Deserialize<'de> for HttpResponse
sourcefn 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
sourceimpl Serialize for HttpResponse
impl Serialize for HttpResponse
Auto Trait Implementations
impl RefUnwindSafe for HttpResponse
impl Send for HttpResponse
impl Sync for HttpResponse
impl Unpin for HttpResponse
impl UnwindSafe for HttpResponse
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more