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); }
/// <summary> /// Exposed Used for testing only! Default values used in the initial settings frame are overridden intentionally /// for testing but violate the RFC if used outside the scope of testing. /// </summary> /// <param name="validateHeaders"></param> /// <param name="hpackDecoder"></param> internal DefaultHttp2HeadersDecoder(bool validateHeaders, HpackDecoder hpackDecoder) { if (hpackDecoder is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.hpackDecoder); } _hpackDecoder = hpackDecoder; _validateHeaders = validateHeaders; _maxHeaderListSizeGoAway = Http2CodecUtil.CalculateMaxHeaderListSizeGoAway(hpackDecoder.GetMaxHeaderListSize()); }