public void TestPassThroughOtherAsClient() { EmbeddedChannel ch = new EmbeddedChannel(new Http2StreamFrameToHttpObjectCodec(false)); IHttp2ResetFrame reset = new DefaultHttp2ResetFrame(0); IHttp2GoAwayFrame goaway = new DefaultHttp2GoAwayFrame(0); Assert.True(ch.WriteInbound(reset)); Assert.True(ch.WriteInbound(goaway.Retain())); Assert.Equal(reset, ch.ReadInbound <object>()); IHttp2GoAwayFrame frame = ch.ReadInbound <IHttp2GoAwayFrame>(); try { Assert.Equal(goaway, frame); Assert.Null(ch.ReadInbound <object>()); Assert.False(ch.Finish()); } finally { goaway.Release(); frame.Release(); } }
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()); }
private void WriteGoAwayFrame(IChannelHandlerContext ctx, IHttp2GoAwayFrame frame, IPromise promise) { if (SharedConstants.TooBigOrNegative >= (uint)frame.LastStreamId) // > -1 { _ = frame.Release(); ThrowHelper.ThrowArgumentException_LastStreamIdMustNotBeSetOnGoAwayFrame(); } int lastStreamCreated = Connection.Remote.LastStreamCreated; long lastStreamId = lastStreamCreated + ((long)frame.ExtraStreamIds) * 2; // Check if the computation overflowed. if (lastStreamId > int.MaxValue) { lastStreamId = int.MaxValue; } _ = GoAwayAsync(ctx, (int)lastStreamId, frame.ErrorCode, frame.Content, promise); }