pub struct ConditionalHeaders {
pub if_none_match: Option<ETagList>,
pub if_match: Option<ETagList>,
pub if_modified_since: Option<SystemTime>,
pub if_unmodified_since: Option<SystemTime>,
}Expand description
Parsed conditional request headers.
Fields§
§if_none_match: Option<ETagList>If-None-Match header (for conditional GET)
if_match: Option<ETagList>If-Match header (for conditional PUT/DELETE)
if_modified_since: Option<SystemTime>If-Modified-Since header
if_unmodified_since: Option<SystemTime>If-Unmodified-Since header
Implementations§
Source§impl ConditionalHeaders
impl ConditionalHeaders
Sourcepub fn from_request(request: &HttpRequest) -> Self
pub fn from_request(request: &HttpRequest) -> Self
Parse conditional headers from an HTTP request.
Lookups use the canonical casing only: HeaderMap::get compares names
with eq_ignore_ascii_case, so a client sending if-none-match is
matched by the same call that matches If-None-Match.
Sourcepub fn is_not_modified(
&self,
etag: Option<&ETag>,
last_modified: Option<SystemTime>,
) -> bool
pub fn is_not_modified( &self, etag: Option<&ETag>, last_modified: Option<SystemTime>, ) -> bool
Check if the resource should return 304 Not Modified.
Returns true if:
- If-None-Match contains a matching ETag (weak comparison), or
- If-Modified-Since is after the resource’s last modification
Sourcepub fn precondition_failed(
&self,
etag: Option<&ETag>,
last_modified: Option<SystemTime>,
) -> bool
pub fn precondition_failed( &self, etag: Option<&ETag>, last_modified: Option<SystemTime>, ) -> bool
Check if the precondition fails (should return 412).
Returns true if:
- If-Match is present and no ETag matches (strong comparison), or
- If-Unmodified-Since is before the resource’s last modification
Trait Implementations§
Source§impl Clone for ConditionalHeaders
impl Clone for ConditionalHeaders
Source§fn clone(&self) -> ConditionalHeaders
fn clone(&self) -> ConditionalHeaders
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 ConditionalHeaders
impl Debug for ConditionalHeaders
Source§impl Default for ConditionalHeaders
impl Default for ConditionalHeaders
Source§fn default() -> ConditionalHeaders
fn default() -> ConditionalHeaders
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ConditionalHeaders
impl RefUnwindSafe for ConditionalHeaders
impl Send for ConditionalHeaders
impl Sync for ConditionalHeaders
impl Unpin for ConditionalHeaders
impl UnsafeUnpin for ConditionalHeaders
impl UnwindSafe for ConditionalHeaders
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<R, D> DepsPresent<D> for R
Source§impl<T> Injectable for T
impl<T> Injectable for T
Source§fn type_id_of() -> TypeIdwhere
Self: Sized,
fn type_id_of() -> TypeIdwhere
Self: Sized,
Returns the TypeId of this type (for internal use)
Source§fn type_name_of() -> &'static strwhere
Self: Sized,
fn type_name_of() -> &'static strwhere
Self: Sized,
Returns the type name for debugging