Skip to main content

forwardable_headers

Function forwardable_headers 

Source
pub fn forwardable_headers(
    headers: &HeaderMap,
    extra_stripped: &[&str],
) -> Vec<(String, String)>
Expand description

The headers of headers that may be forwarded, as lowercase name/value pairs: everything except HOP_BY_HOP_HEADERS, headers named in a Connection header, extra_stripped, and values that aren’t visible ASCII.

§Examples

use guardrail_proxy::forward::{forwardable_headers, STRIPPED_REQUEST_HEADERS};
use reqwest::header::{HeaderMap, HeaderValue};

let mut headers = HeaderMap::new();
headers.insert("authorization", HeaderValue::from_static("Bearer sk-1"));
headers.insert("connection", HeaderValue::from_static("x-trace"));
headers.insert("x-trace", HeaderValue::from_static("1"));
headers.insert("accept-encoding", HeaderValue::from_static("gzip"));

let out = forwardable_headers(&headers, STRIPPED_REQUEST_HEADERS);
assert_eq!(out, vec![("authorization".to_string(), "Bearer sk-1".to_string())]);