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(); } }
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); }