expression

HeaderMap: case-insensitive field names

HTTP field names are case-insensitive. The map stores header values separately from the body. Prefer typed constants when available, and do not assume field values are case-insensitive. External crate example; constructs data in memory, does not send requests. Expected stdout (not executed): Book Common mistake: Lowercasing arbitrary header values as well as names.

Formal Syntax & Structure

rust syntaxrust
headers.insert(name, value); headers.get(name)

Working Example

Example Snippetrust
fn main() {    use http::{HeaderMap, HeaderValue};    let mut h = HeaderMap::new();    h.insert("x-label", HeaderValue::from_static("Book"));    println!("{}", h.get("X-LABEL").unwrap().to_str().unwrap());}
Rust Reference