Skip to main content

Crate vary_header

Crate vary_header 

Source
Expand description

§vary-header — append fields to an HTTP Vary header

Correctly add field names to a Vary response header: de-duplicating case-insensitively, preserving the existing casing, and collapsing to * when appropriate. A faithful Rust port of the vary npm package (used by cors, compression, …). Zero dependencies and #![no_std].

use vary_header::append;

assert_eq!(append("", "Accept").unwrap(), "Accept");
assert_eq!(append("Accept", "Accept-Encoding").unwrap(), "Accept, Accept-Encoding");
assert_eq!(append("Accept", "accept").unwrap(), "Accept"); // already present
assert_eq!(append("Accept", "*").unwrap(), "*");           // varies on everything

Enums§

VaryError
An error returned when a field cannot be appended.

Functions§

append
Append field to a Vary header value, returning the new value.
append_fields
Append several already-separated field names to a Vary header value.