// note that this may behave strangely when used for the initial upgrade // message when using h2c, since that message is ineligible for flow // control, but there is not yet an API for signaling that. internal static void Handle(IChannelHandlerContext ctx, IHttp2Connection connection, IHttp2FrameListener listener, IFullHttpMessage message) { try { int streamId = GetStreamId(connection, message.Headers); IHttp2Stream stream = connection.Stream(streamId); if (stream is null) { stream = connection.Remote.CreateStream(streamId, false); } _ = message.Headers.Set(HttpConversionUtil.ExtensionHeaderNames.Scheme, HttpScheme.Http.Name); IHttp2Headers messageHeaders = HttpConversionUtil.ToHttp2Headers(message, true); var hasContent = message.Content.IsReadable(); var hasTrailers = !message.TrailingHeaders.IsEmpty; listener.OnHeadersRead(ctx, streamId, messageHeaders, 0, !(hasContent || hasTrailers)); if (hasContent) { _ = listener.OnDataRead(ctx, streamId, message.Content, 0, !hasTrailers); } if (hasTrailers) { IHttp2Headers headers = HttpConversionUtil.ToHttp2Headers(message.TrailingHeaders, true); listener.OnHeadersRead(ctx, streamId, headers, 0, true); } _ = stream.CloseRemoteSide(); } finally { _ = message.Release(); } }
public int OnDataRead(IChannelHandlerContext ctx, int streamId, IByteBuffer data, int padding, bool endOfStream) { var stream = this.frameAdapter.GetOrCreateStream(streamId, endOfStream); int processed = listener.OnDataRead(ctx, streamId, data, padding, endOfStream); if (endOfStream) { this.frameAdapter.CloseStream(stream, true); } this.latch.SafeSignal(); return(processed); }
void ReadDataFrame(IChannelHandlerContext ctx, IByteBuffer payload, int payloadEndIndex, IHttp2FrameListener listener) { int padding = ReadPadding(payload); VerifyPadding(padding); // Determine how much data there is to read by removing the trailing // padding. int dataLength = LengthWithoutTrailingPadding(payloadEndIndex - payload.ReaderIndex, padding); IByteBuffer data = payload.ReadSlice(dataLength); _ = listener.OnDataRead(ctx, _streamId, data, padding, _flags.EndOfStream()); }
public virtual int OnDataRead(IChannelHandlerContext ctx, int streamId, IByteBuffer data, int padding, bool endOfStream) { return(_listener.OnDataRead(ctx, streamId, data, padding, endOfStream)); }
public int OnDataRead(IChannelHandlerContext ctx, int streamId, IByteBuffer data, int padding, bool endOfStream) { _logger.LogData(Direction.Inbound, ctx, streamId, data, padding, endOfStream); return(_listener.OnDataRead(ctx, streamId, data, padding, endOfStream)); }