Bug report for `trillium`: Headers::get_values is case-sensitive for unknown header names
divergentdave opened this issue · comments
Describe the bug
When I pass a custom header Headers::get()
, I only get results back if the header name I pass in matches the header on the wire exactly, including case. Known header names are not affected, since they get transformed into an enum. The HeaderName
PartialEq and Hash implementations are correctly case-insensitive, but Headers::get_values()
bypasses that by destructuring the name and comparing the SmartCow
string directly.
To Reproduce
#[cfg(test)]
mod tests {
use trillium_testing::prelude::get;
#[test]
fn same_case() {
let test_conn = get("/").with_request_header("DAP-Auth-Token", "1");
assert!(test_conn.request_headers().get("DAP-Auth-Token").is_some());
}
#[test]
fn different_case() {
let test_conn = get("/").with_request_header("dap-auth-token", "1");
assert!(test_conn.request_headers().get("DAP-Auth-Token").is_none());
}
}
Expected behavior
Both get()
calls should return Some
.