|
| 1 | +macro_rules! def_header_name { |
| 2 | + ($($name:ident => $value:expr),+ $(,)?) => { |
| 3 | + $(paste::paste! { |
| 4 | + #[inline] |
| 5 | + pub(crate) fn [<header_name_ $name>]() -> &'static http::header::HeaderName { |
| 6 | + static HEADER_NAME: std::sync::OnceLock<http::header::HeaderName> = std::sync::OnceLock::new(); |
| 7 | + HEADER_NAME.get_or_init(|| http::header::HeaderName::from_static($value)) |
| 8 | + } |
| 9 | + })+ |
| 10 | + }; |
| 11 | +} |
| 12 | + |
| 13 | +macro_rules! def_header_value { |
| 14 | + ($($name:ident => $value:expr),+ $(,)?) => { |
| 15 | + $(paste::paste! { |
| 16 | + #[inline] |
| 17 | + pub fn [<header_value_ $name>]() -> &'static http::header::HeaderValue { |
| 18 | + static HEADER_NAME: std::sync::OnceLock<http::header::HeaderValue> = std::sync::OnceLock::new(); |
| 19 | + HEADER_NAME.get_or_init(|| http::header::HeaderValue::from_static($value)) |
| 20 | + } |
| 21 | + })+ |
| 22 | + }; |
| 23 | +} |
| 24 | + |
| 25 | +def_header_value!( |
| 26 | + one => "1", |
| 27 | + encoding => "gzip", |
| 28 | + encodings => "gzip,br", |
| 29 | + accept => "*/*", |
| 30 | + language => "en-US", |
| 31 | + empty => "empty", |
| 32 | + cors => "cors", |
| 33 | + no_cache => "no-cache", |
| 34 | + no_cache_revalidate => "no-cache, must-revalidate", |
| 35 | + ua_win => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36", |
| 36 | + same_origin => "same-origin", |
| 37 | + keep_alive => "keep-alive", |
| 38 | + trailers => "trailers", |
| 39 | + u_eq_0 => "u=0", |
| 40 | + connect_es => "connect-es/1.6.1", |
| 41 | + not_a_brand => "\"Not-A.Brand\";v=\"99\", \"Chromium\";v=\"124\"", |
| 42 | + mobile_no => "?0", |
| 43 | + windows => "\"Windows\"", |
| 44 | + ua_cursor => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Cursor/0.42.5 Chrome/124.0.6367.243 Electron/30.4.0 Safari/537.36", |
| 45 | + vscode_origin => "vscode-file://vscode-app", |
| 46 | + cross_site => "cross-site", |
| 47 | + gzip_deflate => "gzip, deflate", |
| 48 | + event_stream => "text/event-stream", |
| 49 | + chunked => "chunked", |
| 50 | + json => "application/json", |
| 51 | + proto => "application/proto", |
| 52 | + connect_proto => "application/connect+proto", |
| 53 | + |
| 54 | + // Content type constants |
| 55 | + text_html_utf8 => "text/html;charset=utf-8", |
| 56 | + text_plain_utf8 => "text/plain;charset=utf-8", |
| 57 | + text_css_utf8 => "text/css;charset=utf-8", |
| 58 | + text_js_utf8 => "text/javascript;charset=utf-8" |
| 59 | +); |
| 60 | + |
| 61 | +def_header_name!( |
| 62 | + proxy_host => "x-co", |
| 63 | + connect_accept_encoding => "connect-accept-encoding", |
| 64 | + connect_protocol_version => "connect-protocol-version", |
| 65 | + ghost_mode => "x-ghost-mode", |
| 66 | + amzn_trace_id => "x-amzn-trace-id", |
| 67 | + client_key => "x-client-key", |
| 68 | + cursor_checksum => "x-cursor-checksum", |
| 69 | + cursor_client_version => "x-cursor-client-version", |
| 70 | + cursor_timezone => "x-cursor-timezone", |
| 71 | + request_id => "x-request-id", |
| 72 | + sec_ch_ua => "sec-ch-ua", |
| 73 | + sec_ch_ua_mobile => "sec-ch-ua-mobile", |
| 74 | + sec_ch_ua_platform => "sec-ch-ua-platform", |
| 75 | + sec_fetch_dest => "sec-fetch-dest", |
| 76 | + sec_fetch_mode => "sec-fetch-mode", |
| 77 | + sec_fetch_site => "sec-fetch-site", |
| 78 | + sec_gpc => "sec-gpc", |
| 79 | + priority => "priority", |
| 80 | +); |
0 commit comments