Skip to main content

check_if_none_match

Function check_if_none_match 

Source
pub fn check_if_none_match(if_none_match: &str, current_etag: &str) -> bool
Expand description

Check an If-None-Match header value against an ETag.

Returns true if the condition is met (i.e., the resource HAS changed and the full response should be sent). Returns false if a 304 Not Modified should be returned instead.

Handles:

  • * wildcard (matches any ETag)
  • Multiple comma-separated ETags
  • Weak ETag comparison (W/ prefix stripped for comparison)

§Example

use fastapi_core::response::check_if_none_match;

let current_etag = "\"abc123\"";
let if_none_match = "\"abc123\"";
// Returns false: ETag matches, so send 304
assert!(!check_if_none_match(if_none_match, current_etag));