public KnownHeader(string name, HttpHeaderType headerType, HttpHeaderParser parser, string[] knownValues = null) { Debug.Assert(!string.IsNullOrEmpty(name)); Debug.Assert(HttpRuleParser.GetTokenLength(name, 0) == name.Length); Debug.Assert(headerType != HttpHeaderType.Custom); Debug.Assert(parser != null); _name = name; _headerType = headerType; _parser = parser; _knownValues = knownValues; }
private HttpHeaderParser GetParser(string name) { if (parserStore == null) { return(null); } HttpHeaderParser parser = null; if (parserStore.TryGetValue(name, out parser)) { return(parser); } return(null); }
public KnownHeader(string name, HttpHeaderType headerType, HttpHeaderParser parser, string[] knownValues = null) { Debug.Assert(!string.IsNullOrEmpty(name)); Debug.Assert(HttpRuleParser.GetTokenLength(name, 0) == name.Length); Debug.Assert((headerType == HttpHeaderType.Custom) == (parser == null)); Debug.Assert(knownValues == null || headerType != HttpHeaderType.Custom); _name = name; _headerType = headerType; _parser = parser; _knownValues = knownValues; _asciiBytesWithColonSpace = new byte[name.Length + 2]; // + 2 for ':' and ' ' Array.Copy(Encoding.ASCII.GetBytes(name), _asciiBytesWithColonSpace, name.Length); _asciiBytesWithColonSpace[_asciiBytesWithColonSpace.Length - 2] = (byte)':'; _asciiBytesWithColonSpace[_asciiBytesWithColonSpace.Length - 1] = (byte)' '; }
public KnownHeader(string name, HttpHeaderType headerType, HttpHeaderParser parser, string[] knownValues = null, int?http2StaticTableIndex = null) { Debug.Assert(!string.IsNullOrEmpty(name)); Debug.Assert(HttpRuleParser.GetTokenLength(name, 0) == name.Length); Debug.Assert((headerType == HttpHeaderType.Custom) == (parser == null)); Debug.Assert(knownValues == null || headerType != HttpHeaderType.Custom); Name = name; HeaderType = headerType; Parser = parser; KnownValues = knownValues; Http2EncodedName = http2StaticTableIndex.HasValue ? HPackEncoder.EncodeLiteralHeaderFieldWithoutIndexingToAllocatedArray(http2StaticTableIndex.GetValueOrDefault()) : HPackEncoder.EncodeLiteralHeaderFieldWithoutIndexingNewNameToAllocatedArray(name); var asciiBytesWithColonSpace = new byte[name.Length + 2]; // + 2 for ':' and ' ' int asciiBytes = Encoding.ASCII.GetBytes(name, asciiBytesWithColonSpace); Debug.Assert(asciiBytes == name.Length); asciiBytesWithColonSpace[asciiBytesWithColonSpace.Length - 2] = (byte)':'; asciiBytesWithColonSpace[asciiBytesWithColonSpace.Length - 1] = (byte)' '; AsciiBytesWithColonSpace = asciiBytesWithColonSpace; }
public MockHeaders(string headerName, HttpHeaderParser parser) { Dictionary<string, HttpHeaderParser> parserStore = new Dictionary<string, HttpHeaderParser>(); parserStore.Add(headerName, parser); SetConfiguration(parserStore, new HashSet<string>()); }
internal HeaderStoreItemInfo(HttpHeaderParser parser) { // Can be null. this.parser = parser; }