pub enum IfRange {
Date(HeaderValue),
ETag(HeaderValue),
}Expand description
A typed HTTP If-Range header.
Per RFC 9110 Section 13.1.5, If-Range can contain either an HTTP-date
or an entity-tag. When present alongside a Range header, the server must
evaluate the validator against the current representation:
- If the validator matches, the
Rangeis honored (206 Partial Content). - If the validator does not match, the
Rangeis ignored and the full representation is served (200 OK).
Variants§
Date(HeaderValue)
An HTTP-date validator (the raw header value, to be compared with Last-Modified).
ETag(HeaderValue)
An entity-tag validator (the raw header value, to be compared with ETag).
Implementations§
Source§impl IfRange
impl IfRange
Sourcepub fn evaluate(
&self,
range: HttpRange,
last_modified: Option<&HeaderValue>,
etag: Option<&HeaderValue>,
) -> Option<HttpRange>
pub fn evaluate( &self, range: HttpRange, last_modified: Option<&HeaderValue>, etag: Option<&HeaderValue>, ) -> Option<HttpRange>
Evaluates the If-Range condition and returns the HttpRange only if
the condition holds.
range: the parsedRangeheader value.last_modified: the currentLast-Modifiedheader of the representation.etag: the currentETagheader of the representation.
Returns Some(range) if the validator matches (the range should be
honored), or None if it does not (the full representation should be
served).
Per RFC 9110 Section 13.1.5, the comparison uses the raw header values:
- For dates, the
If-Rangevalue must be an exact byte-for-byte match of theLast-Modifiedheader value. - For entity-tags, the
If-Rangevalue must be a strong comparison match against theETagheader value. Weak entity-tags never match.
Trait Implementations§
Source§impl<S> OptionalFromRequestParts<S> for IfRange
Available on crate feature axum only.
impl<S> OptionalFromRequestParts<S> for IfRange
Available on crate feature
axum only.Source§impl TryFrom<&HeaderValue> for IfRange
impl TryFrom<&HeaderValue> for IfRange
Source§type Error = InvalidIfRange
type Error = InvalidIfRange
The type returned in the event of a conversion error.
impl Eq for IfRange
impl StructuralPartialEq for IfRange
Auto Trait Implementations§
impl !Freeze for IfRange
impl RefUnwindSafe for IfRange
impl Send for IfRange
impl Sync for IfRange
impl Unpin for IfRange
impl UnsafeUnpin for IfRange
impl UnwindSafe for IfRange
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