Skip to main content

parse_if_range_at

Function parse_if_range_at 

Source
pub fn parse_if_range_at(
    value: &[u8],
    now: i64,
) -> Result<IfRange<'_>, ParseError>
Expand description

Parses If-Range: an entity tag when the value starts with W/ or ", an HTTP-date otherwise, in any of the three forms (RFC 9110 section 5.6.7). now (Unix seconds) places the two-digit year of an RFC 850 date. Use it over parse_if_range when a clock is at hand.

§Errors

The errors of EntityTag::parse or HttpDate::parse_at.

§Examples

use parse_net::range::parse_if_range_at;

let now = 1_792_540_800;
let imf = parse_if_range_at(b"Sun, 06 Nov 1994 08:49:37 GMT", now)?;
assert_eq!(parse_if_range_at(b"Sunday, 06-Nov-94 08:49:37 GMT", now)?, imf);
assert_eq!(parse_if_range_at(b"Sun Nov  6 08:49:37 1994", now)?, imf);