コード例 #1
0
ファイル: DynamicTable.cs プロジェクト: sondreb/MithrilShards
        public void Resize(int maxSize)
        {
            if (maxSize > _maxSize)
            {
                var newBuffer = new HeaderField[maxSize / HeaderField.RfcOverhead];

                for (var i = 0; i < Count; i++)
                {
                    newBuffer[i] = _buffer[i];
                }

                _buffer  = newBuffer;
                _maxSize = maxSize;
            }
            else
            {
                _maxSize = maxSize;
                EnsureAvailable(0);
            }
        }
コード例 #2
0
ファイル: DynamicTable.cs プロジェクト: sondreb/MithrilShards
        public void Insert(Span <byte> name, Span <byte> value)
        {
            var entryLength = HeaderField.GetLength(name.Length, value.Length);

            EnsureAvailable(entryLength);

            if (entryLength > _maxSize)
            {
                // http://httpwg.org/specs/rfc7541.html#rfc.section.4.4
                // It is not an error to attempt to add an entry that is larger than the maximum size;
                // an attempt to add an entry larger than the maximum size causes the table to be emptied
                // of all existing entries and results in an empty table.
                return;
            }

            var entry = new HeaderField(name, value);

            _buffer[_insertIndex] = entry;
            _insertIndex          = (_insertIndex + 1) % _buffer.Length;
            _size += entry.Length;
            _count++;
        }