Skip to main content

parse_raw_headers

Function parse_raw_headers 

Source
pub fn parse_raw_headers(raw: &str) -> (Vec<(String, String)>, &str)
Expand description

Parses headers from a raw email, returning an ordered list of headers and a reference to the content after the blank-line separator.

Headers are preserved in their original order with case-preserved keys and trimmed values. This supports duplicate headers (e.g. Received).

ยงExamples

let (headers, content) = mailsis_utils::parse_raw_headers(
    "From: alice@example.com\r\nTo: bob@example.com\r\n\r\nHello!"
);
assert_eq!(headers.len(), 2);
assert_eq!(headers[0], ("From".to_string(), "alice@example.com".to_string()));
assert_eq!(content, "Hello!");