示例#1
0
        public void DecodesIncompleteHeaderBlock_Error(byte[] encoded)
        {
            HPackDecodingException exception = Assert.Throws <HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));

            Assert.Equal(SR.net_http_hpack_incomplete_header_block, exception.Message);
            Assert.Empty(_handler.DecodedHeaders);
        }
示例#2
0
        public void WrapsHuffmanDecodingExceptionInHPackDecodingException(byte[] encoded)
        {
            HPackDecodingException exception = Assert.Throws <HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));

            Assert.Equal(SR.net_http_hpack_huffman_decode_failed, exception.Message);
            Assert.IsType <HuffmanDecodingException>(exception.InnerException);
            Assert.Empty(_handler.DecodedHeaders);
        }
示例#3
0
        public void DecodesIndexedHeaderField_OutOfRange_Error()
        {
            HPackDecodingException exception = Assert.Throws <HPackDecodingException>(() =>
                                                                                      _decoder.Decode(_indexedHeaderDynamic, endHeaders: true, handler: _handler));

            Assert.Equal(SR.Format(SR.net_http_hpack_invalid_index, 62), exception.Message);
            Assert.Empty(_handler.DecodedHeaders);
        }
示例#4
0
        public void DecodesStringLength_GreaterThanLimit_Error()
        {
            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
                             .Concat(new byte[] { 0xff, 0x82, 0x3f }) // 8193 encoded with 7-bit prefix
                             .ToArray();

            HPackDecodingException exception = Assert.Throws <HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));

            Assert.Equal(SR.Format(SR.net_http_headers_exceeded_length, MaxHeaderFieldSize), exception.Message);
            Assert.Empty(_handler.DecodedHeaders);
        }
示例#5
0
        public void DecodesLiteralHeaderFieldNeverIndexed_IndexedName_OutOfRange_Error()
        {
            // 0001           (Literal Header Field Never Indexed Representation)
            // 1111 0010 1111 (Indexed Name - Index 62 encoded with 4-bit prefix - see http://httpwg.org/specs/rfc7541.html#integer.representation)
            // Index 62 is the first entry in the dynamic table. If there's nothing there, the decoder should throw.

            HPackDecodingException exception = Assert.Throws <HPackDecodingException>(() => _decoder.Decode(new byte[] { 0x1f, 0x2f }, endHeaders: true, handler: _handler));

            Assert.Equal(SR.Format(SR.net_http_hpack_invalid_index, 62), exception.Message);
            Assert.Empty(_handler.DecodedHeaders);
        }
示例#6
0
        public void DecodesDynamicTableSizeUpdate_AfterIndexedHeaderStatic_Error()
        {
            // 001   (Dynamic Table Size Update)
            // 11110 (30 encoded with 5-bit prefix - see http://httpwg.org/specs/rfc7541.html#integer.representation)

            Assert.Equal(DynamicTableInitialMaxSize, _dynamicTable.MaxSize);

            byte[] data = _indexedHeaderStatic.Concat(new byte[] { 0x3e }).ToArray();
            HPackDecodingException exception = Assert.Throws <HPackDecodingException>(() => _decoder.Decode(data, endHeaders: true, handler: _handler));

            Assert.Equal(SR.net_http_hpack_late_dynamic_table_size_update, exception.Message);
        }
示例#7
0
        public void DecodesDynamicTableSizeUpdate_GreaterThanLimit_Error()
        {
            // 001                     (Dynamic Table Size Update)
            // 11111 11100010 00011111 (4097 encoded with 5-bit prefix - see http://httpwg.org/specs/rfc7541.html#integer.representation)

            Assert.Equal(DynamicTableInitialMaxSize, _dynamicTable.MaxSize);

            HPackDecodingException exception = Assert.Throws <HPackDecodingException>(() =>
                                                                                      _decoder.Decode(new byte[] { 0x3f, 0xe2, 0x1f }, endHeaders: true, handler: _handler));

            Assert.Equal(SR.Format(SR.net_http_hpack_large_table_size_update, 4097, DynamicTableInitialMaxSize), exception.Message);
            Assert.Empty(_handler.DecodedHeaders);
        }
示例#8
0
        public void DecodesDynamicTableSizeUpdate_AfterIndexedHeaderStatic_SubsequentDecodeCall_Error()
        {
            Assert.Equal(DynamicTableInitialMaxSize, _dynamicTable.MaxSize);

            _decoder.Decode(_indexedHeaderStatic, endHeaders: false, handler: _handler);
            Assert.Equal("GET", _handler.DecodedHeaders[":method"]);

            // 001   (Dynamic Table Size Update)
            // 11110 (30 encoded with 5-bit prefix - see http://httpwg.org/specs/rfc7541.html#integer.representation)
            byte[] data = new byte[] { 0x3e };
            HPackDecodingException exception = Assert.Throws <HPackDecodingException>(() => _decoder.Decode(data, endHeaders: true, handler: _handler));

            Assert.Equal(SR.net_http_hpack_late_dynamic_table_size_update, exception.Message);
        }
示例#9
0
 public virtual void HPackDecodingError(string connectionId, int streamId, HPackDecodingException ex)
 {
     _hpackDecodingError(_logger, connectionId, streamId, ex);
 }
示例#10
0
 public void HPackDecodingError(string connectionId, int streamId, HPackDecodingException ex)
 {
 }
示例#11
0
 public void HPackDecodingError(string connectionId, int streamId, HPackDecodingException ex)
 {
     _trace1.HPackDecodingError(connectionId, streamId, ex);
     _trace2.HPackDecodingError(connectionId, streamId, ex);
 }