sark-http 0.38.0

HTTP wire types, semantics, codecs, and ownership invariants for Sark
Documentation
pub(in crate::field) const HOST: &str = "host";
pub(in crate::field) const CONNECTION: &str = "connection";
pub(in crate::field) const CONTENT_LENGTH: &str = "content-length";
pub(in crate::field) const TRANSFER_ENCODING: &str = "transfer-encoding";
pub(in crate::field) const EXPECT: &str = "expect";
pub(in crate::field) const ACCEPT_ENCODING: &str = "accept-encoding";
pub(in crate::field) const TE: &str = "te";
pub(in crate::field) const KEEP_ALIVE: &str = "keep-alive";
pub(in crate::field) const PROXY_CONNECTION: &str = "proxy-connection";
pub(in crate::field) const UPGRADE: &str = "upgrade";
pub(in crate::field) const CONTENT_TYPE: &str = "content-type";

/// Canonical standard field-name vocabulary shared by owned headers and H1.
pub(in crate::field) fn from_bytes(name: &[u8]) -> Option<&'static str> {
    let mut lower = [0_u8; 35];
    let bytes = lower.get_mut(..name.len())?;
    for (out, byte) in bytes.iter_mut().zip(name) {
        *out = byte.to_ascii_lowercase();
    }
    match &*bytes {
        b"accept" => Some("accept"),
        b"accept-charset" => Some("accept-charset"),
        b"accept-encoding" => Some(ACCEPT_ENCODING),
        b"accept-language" => Some("accept-language"),
        b"accept-ranges" => Some("accept-ranges"),
        b"access-control-allow-credentials" => Some("access-control-allow-credentials"),
        b"access-control-allow-headers" => Some("access-control-allow-headers"),
        b"access-control-allow-methods" => Some("access-control-allow-methods"),
        b"access-control-allow-origin" => Some("access-control-allow-origin"),
        b"access-control-expose-headers" => Some("access-control-expose-headers"),
        b"access-control-max-age" => Some("access-control-max-age"),
        b"access-control-request-headers" => Some("access-control-request-headers"),
        b"access-control-request-method" => Some("access-control-request-method"),
        b"age" => Some("age"),
        b"allow" => Some("allow"),
        b"alt-svc" => Some("alt-svc"),
        b"authorization" => Some("authorization"),
        b"cache-control" => Some("cache-control"),
        b"cache-status" => Some("cache-status"),
        b"cdn-cache-control" => Some("cdn-cache-control"),
        b"connection" => Some(CONNECTION),
        b"content-disposition" => Some("content-disposition"),
        b"content-encoding" => Some("content-encoding"),
        b"content-language" => Some("content-language"),
        b"content-length" => Some(CONTENT_LENGTH),
        b"content-location" => Some("content-location"),
        b"content-range" => Some("content-range"),
        b"content-security-policy" => Some("content-security-policy"),
        b"content-security-policy-report-only" => Some("content-security-policy-report-only"),
        b"content-type" => Some(CONTENT_TYPE),
        b"cookie" => Some("cookie"),
        b"date" => Some("date"),
        b"dnt" => Some("dnt"),
        b"etag" => Some("etag"),
        b"expect" => Some(EXPECT),
        b"expires" => Some("expires"),
        b"forwarded" => Some("forwarded"),
        b"from" => Some("from"),
        b"host" => Some(HOST),
        b"if-match" => Some("if-match"),
        b"if-modified-since" => Some("if-modified-since"),
        b"if-none-match" => Some("if-none-match"),
        b"if-range" => Some("if-range"),
        b"if-unmodified-since" => Some("if-unmodified-since"),
        b"keep-alive" => Some(KEEP_ALIVE),
        b"last-modified" => Some("last-modified"),
        b"link" => Some("link"),
        b"location" => Some("location"),
        b"max-forwards" => Some("max-forwards"),
        b"origin" => Some("origin"),
        b"pragma" => Some("pragma"),
        b"proxy-authenticate" => Some("proxy-authenticate"),
        b"proxy-authorization" => Some("proxy-authorization"),
        b"proxy-connection" => Some(PROXY_CONNECTION),
        b"public-key-pins" => Some("public-key-pins"),
        b"public-key-pins-report-only" => Some("public-key-pins-report-only"),
        b"range" => Some("range"),
        b"referer" => Some("referer"),
        b"referrer-policy" => Some("referrer-policy"),
        b"refresh" => Some("refresh"),
        b"retry-after" => Some("retry-after"),
        b"sec-websocket-accept" => Some("sec-websocket-accept"),
        b"sec-websocket-extensions" => Some("sec-websocket-extensions"),
        b"sec-websocket-key" => Some("sec-websocket-key"),
        b"sec-websocket-protocol" => Some("sec-websocket-protocol"),
        b"sec-websocket-version" => Some("sec-websocket-version"),
        b"server" => Some("server"),
        b"set-cookie" => Some("set-cookie"),
        b"strict-transport-security" => Some("strict-transport-security"),
        b"te" => Some(TE),
        b"trailer" => Some("trailer"),
        b"transfer-encoding" => Some(TRANSFER_ENCODING),
        b"upgrade" => Some(UPGRADE),
        b"upgrade-insecure-requests" => Some("upgrade-insecure-requests"),
        b"user-agent" => Some("user-agent"),
        b"vary" => Some("vary"),
        b"via" => Some("via"),
        b"warning" => Some("warning"),
        b"www-authenticate" => Some("www-authenticate"),
        b"x-content-type-options" => Some("x-content-type-options"),
        b"x-dns-prefetch-control" => Some("x-dns-prefetch-control"),
        b"x-frame-options" => Some("x-frame-options"),
        b"x-xss-protection" => Some("x-xss-protection"),
        _ => None,
    }
}