// 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); }
public override bool Equals(object?obj) => throw new InvalidOperationException(); // Ensure this is never called, to avoid boxing // Returns false for invalid header name. public static bool TryGet(string headerName, out HeaderDescriptor descriptor) { Debug.Assert(!string.IsNullOrEmpty(headerName)); 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(headerName); return(true); }