Esempio n. 1
0
        // Returns false for invalid header name.
        public static bool TryGet(ReadOnlySpan <byte> headerName, out HeaderDescriptor descriptor)
        {
            Debug.Assert(headerName.Length > 0);

            KnownHeader?knownHeader = KnownHeaders.TryGetKnownHeader(headerName);

            if (knownHeader != null)
            {
                descriptor = new HeaderDescriptor(knownHeader);
                return(true);
            }

            if (!HttpRuleParser.IsToken(headerName))
            {
                descriptor = default(HeaderDescriptor);
                return(false);
            }

            descriptor = new HeaderDescriptor(HttpRuleParser.GetTokenString(headerName));
            return(true);
        }