Esempio n. 1
0
        public void TestPassThroughOther()
        {
            EmbeddedChannel   ch     = new EmbeddedChannel(new Http2StreamFrameToHttpObjectCodec(true));
            IHttp2ResetFrame  reset  = new DefaultHttp2ResetFrame(Http2Error.NoError);
            IHttp2GoAwayFrame goaway = new DefaultHttp2GoAwayFrame(Http2Error.NoError);

            Assert.True(ch.WriteInbound(reset));
            Assert.True(ch.WriteInbound(goaway.Retain()));

            Assert.Equal(reset, ch.ReadInbound <IHttp2ResetFrame>());

            var frame = ch.ReadInbound <IHttp2GoAwayFrame>();

            try
            {
                Assert.Equal(goaway, frame);
                Assert.Null(ch.ReadInbound <object>());
                Assert.False(ch.Finish());
            }
            finally
            {
                goaway.Release();
                frame.Release();
            }
        }
Esempio n. 2
0
        public void ReceiveRstStream()
        {
            _frameInboundWriter.WriteInboundHeaders(3, _request, 31, false);

            IHttp2Stream stream = _frameCodec.Connection.Stream(3);

            Assert.NotNull(stream);
            Assert.Equal(Http2StreamState.Open, stream.State);

            IHttp2HeadersFrame expectedHeaders = new DefaultHttp2HeadersFrame(_request, false, 31);
            IHttp2HeadersFrame actualHeaders   = _inboundHandler.ReadInbound <IHttp2HeadersFrame>();

            expectedHeaders.Stream = actualHeaders.Stream;
            Assert.Equal(expectedHeaders, actualHeaders);

            _frameInboundWriter.WriteInboundRstStream(3, Http2Error.NoError);

            IHttp2ResetFrame expectedRst = new DefaultHttp2ResetFrame(Http2Error.NoError)
            {
                Stream = actualHeaders.Stream
            };
            IHttp2ResetFrame actualRst = _inboundHandler.ReadInbound <IHttp2ResetFrame>();

            Assert.Equal(expectedRst, actualRst);

            Assert.Null(_inboundHandler.ReadInbound());
        }