pub trait ConditionalRequest {
// Required methods
fn conditional_headers(&self) -> ConditionalHeaders;
fn if_none_match(&self) -> Option<ETagList>;
fn if_match(&self) -> Option<ETagList>;
fn if_modified_since(&self) -> Option<SystemTime>;
fn if_unmodified_since(&self) -> Option<SystemTime>;
fn if_none_match_matches(&self, etag: &ETag) -> bool;
fn if_match_matches(&self, etag: &ETag) -> bool;
fn not_modified_since(&self, last_modified: SystemTime) -> bool;
fn modified_since_precondition(&self, last_modified: SystemTime) -> bool;
fn evaluate_conditionals(
&self,
etag: Option<&ETag>,
last_modified: Option<SystemTime>,
) -> Option<u16>;
}Expand description
Extension trait for conditional request handling on HttpRequest.
Required Methods§
Sourcefn conditional_headers(&self) -> ConditionalHeaders
fn conditional_headers(&self) -> ConditionalHeaders
Get parsed conditional headers from the request.
Sourcefn if_none_match(&self) -> Option<ETagList>
fn if_none_match(&self) -> Option<ETagList>
Get the If-None-Match header as an ETag list.
Sourcefn if_modified_since(&self) -> Option<SystemTime>
fn if_modified_since(&self) -> Option<SystemTime>
Get the If-Modified-Since header as a SystemTime.
Sourcefn if_unmodified_since(&self) -> Option<SystemTime>
fn if_unmodified_since(&self) -> Option<SystemTime>
Get the If-Unmodified-Since header as a SystemTime.
Sourcefn if_none_match_matches(&self, etag: &ETag) -> bool
fn if_none_match_matches(&self, etag: &ETag) -> bool
Check if If-None-Match contains a matching ETag (weak comparison).
Returns true if the request should get a 304 Not Modified response.
Sourcefn if_match_matches(&self, etag: &ETag) -> bool
fn if_match_matches(&self, etag: &ETag) -> bool
Check if If-Match contains a matching ETag (strong comparison).
Returns false if the precondition fails (should return 412).
Sourcefn not_modified_since(&self, last_modified: SystemTime) -> bool
fn not_modified_since(&self, last_modified: SystemTime) -> bool
Check if If-Modified-Since indicates the resource hasn’t changed.
Sourcefn modified_since_precondition(&self, last_modified: SystemTime) -> bool
fn modified_since_precondition(&self, last_modified: SystemTime) -> bool
Check if If-Unmodified-Since precondition fails.
Sourcefn evaluate_conditionals(
&self,
etag: Option<&ETag>,
last_modified: Option<SystemTime>,
) -> Option<u16>
fn evaluate_conditionals( &self, etag: Option<&ETag>, last_modified: Option<SystemTime>, ) -> Option<u16>
Evaluate all conditional headers and return the appropriate response.
Returns:
Some(304)if resource is not modifiedSome(412)if precondition failedNoneif request should proceed normally
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".