use axum::response::Response;
pub fn ascii_ify(s: &str) -> String {
let mut result = String::with_capacity(s.len());
for c in s.chars() {
let code = c as u32;
if (0x20..=0x7E).contains(&code) {
result.push(c);
} else {
result.push_str(&format!("\\u{:04x}", code));
}
}
result
}
pub fn free_cors_headers() -> Vec<(&'static str, &'static str)> {
vec![
("access-control-allow-origin", "*"),
("access-control-allow-methods", "*"),
("access-control-allow-headers", "*"),
("access-control-expose-headers", "*"),
]
}
pub fn apply_free_cors(response: &mut Response) {
let headers = response.headers_mut();
for (name, value) in free_cors_headers() {
headers.insert(
axum::http::header::HeaderName::from_static(name),
axum::http::header::HeaderValue::from_static(value),
);
}
}
pub const FIREFOX_EXTRA_NEWLINES: usize = 240;