public void ReceiveGoaway() { IByteBuffer debugData = Http2TestUtil.BB("foo"); _frameInboundWriter.WriteInboundGoAway(2, Http2Error.NoError, debugData); IHttp2GoAwayFrame expectedFrame = new DefaultHttp2GoAwayFrame(2, Http2Error.NoError, Http2TestUtil.BB("foo")); IHttp2GoAwayFrame actualFrame = _inboundHandler.ReadInbound <IHttp2GoAwayFrame>(); Http2TestUtil.AssertEqualsAndRelease(expectedFrame, actualFrame); Assert.Null(_inboundHandler.ReadInbound()); }
public void EntityRequestEntityResponse() { _frameInboundWriter.WriteInboundHeaders(1, _request, 0, false); IHttp2Stream stream = _frameCodec.Connection.Stream(1); Assert.NotNull(stream); Assert.Equal(Http2StreamState.Open, stream.State); IHttp2HeadersFrame inboundHeaders = _inboundHandler.ReadInbound <IHttp2HeadersFrame>(); IHttp2FrameStream stream2 = inboundHeaders.Stream; Assert.NotNull(stream2); Assert.Equal(1, stream2.Id); Assert.Equal(new DefaultHttp2HeadersFrame(_request, false) { Stream = stream2 }, inboundHeaders); Assert.Null(_inboundHandler.ReadInbound()); IByteBuffer hello = Http2TestUtil.BB("hello"); _frameInboundWriter.WriteInboundData(1, hello, 31, true); IHttp2DataFrame inboundData = _inboundHandler.ReadInbound <IHttp2DataFrame>(); IHttp2DataFrame expected = new DefaultHttp2DataFrame(Http2TestUtil.BB("hello"), true, 31) { Stream = stream2 }; Http2TestUtil.AssertEqualsAndRelease(expected, inboundData); Assert.Null(_inboundHandler.ReadInbound()); _channel.WriteOutbound(new DefaultHttp2HeadersFrame(_response, false) { Stream = stream2 }); _frameWriter.Verify( x => x.WriteHeadersAsync( It.Is <IChannelHandlerContext>(v => v == _frameCodec._ctx), It.Is <int>(v => v == 1), It.Is <IHttp2Headers>(v => v.Equals(_response)), It.Is <int>(v => v == 0), It.Is <bool>(v => v == false), It.IsAny <IPromise>())); _channel.WriteOutbound(new DefaultHttp2DataFrame(Http2TestUtil.BB("world"), true, 27) { Stream = stream2 }); var outboundData = new ArgumentCaptor <IByteBuffer>(); _frameWriter.Verify( x => x.WriteDataAsync( It.Is <IChannelHandlerContext>(v => v == _frameCodec._ctx), It.Is <int>(v => v == 1), It.Is <IByteBuffer>(v => outboundData.Capture(v)), It.Is <int>(v => v == 27), It.Is <bool>(v => v == true), It.IsAny <IPromise>())); IByteBuffer bb = Http2TestUtil.BB("world"); Assert.Equal(bb, outboundData.GetValue()); Assert.Equal(1, outboundData.GetValue().ReferenceCount); bb.Release(); outboundData.GetValue().Release(); _frameWriter.Verify( x => x.WriteRstStreamAsync( It.Is <IChannelHandlerContext>(v => v == _frameCodec._ctx), It.IsAny <int>(), It.IsAny <Http2Error>(), It.IsAny <IPromise>()), Times.Never()); Assert.True(_channel.IsActive); }