示例#1
0
        /// <summary>
        /// Creates a new HPACK decoder
        /// </summary>
        /// <param name="options">Decoder options</param>
        public Decoder(Options?options)
        {
            var dynamicTableSize = Defaults.DynamicTableSize;

            this._dynamicTableSizeLimit = Defaults.DynamicTableSizeLimit;
            var maxStringLength         = Defaults.MaxStringLength;
            ArrayPool <byte> bufferPool = null;

            if (options.HasValue)
            {
                var opts = options.Value;
                if (opts.DynamicTableSize.HasValue)
                {
                    dynamicTableSize = opts.DynamicTableSize.Value;
                }
                if (opts.DynamicTableSizeLimit.HasValue)
                {
                    this._dynamicTableSizeLimit = opts.DynamicTableSizeLimit.Value;
                }
                if (opts.MaxStringLength.HasValue)
                {
                    maxStringLength = opts.MaxStringLength.Value;
                }
                if (opts.BufferPool != null)
                {
                    bufferPool = opts.BufferPool;
                }
            }

            if (bufferPool == null)
            {
                bufferPool = ArrayPool <byte> .Shared;
            }

            this._stringDecoder = new StringDecoder(maxStringLength, bufferPool);

            if (dynamicTableSize > this._dynamicTableSizeLimit)
            {
                throw new ArgumentException("Dynamic table size must not exceeded limit");
            }

            this._headerTable = new HeaderTable(dynamicTableSize);
        }
示例#2
0
 public void Dispose()
 {
     _stringDecoder.Dispose();
     _stringDecoder = null;
 }