Esempio n. 1
0
        public void AppendToHeaderList(ICharSequence name, ICharSequence value)
        {
            _headersLength     += HpackHeaderField.SizeOf(name, value);
            _exceededMaxLength |= _headersLength > _maxHeaderListSize;

            if (_exceededMaxLength || _validationException is object)
            {
                // We don't store the header since we've already failed validation requirements.
                return;
            }

            if (_validate)
            {
                try
                {
                    _previousType = HpackDecoder.Validate(_streamId, name, _previousType);
                }
                catch (Http2Exception ex)
                {
                    _validationException = ex;
                    return;
                }
            }

            _ = _headers.Add(name, value);
        }
Esempio n. 2
0
        void EncodeHeadersEnforceMaxHeaderListSize(int streamId, IByteBuffer output, IHttp2Headers headers, ISensitivityDetector sensitivityDetector)
        {
            long headerSize = 0;

            // To ensure we stay consistent with our peer check the size is valid before we potentially modify HPACK state.
            foreach (HeaderEntry <ICharSequence, ICharSequence> header in headers)
            {
                ICharSequence name  = header.Key;
                ICharSequence value = header.Value;
                // OK to increment now and check for bounds after because this value is limited to unsigned int and will not
                // overflow.
                headerSize += HpackHeaderField.SizeOf(name, value);
                if (headerSize > _maxHeaderListSize)
                {
                    Http2CodecUtil.HeaderListSizeExceeded(streamId, _maxHeaderListSize, false);
                }
            }

            EncodeHeadersIgnoreMaxHeaderListSize(@output, headers, sensitivityDetector);
        }
Esempio n. 3
0
 void EncodeHeadersIgnoreMaxHeaderListSize(IByteBuffer output, IHttp2Headers headers, ISensitivityDetector sensitivityDetector)
 {
     foreach (HeaderEntry <ICharSequence, ICharSequence> header in headers)
     {
         ICharSequence name  = header.Key;
         ICharSequence value = header.Value;
         EncodeHeader(output, name, value, sensitivityDetector.IsSensitive(name, value), HpackHeaderField.SizeOf(name, value));
     }
 }