use of io.netty.handler.codec.http2.Http2Stream in project micronaut-core by micronaut-projects.
the class StreamingInboundHttp2ToHttpAdapter method onDataRead.
@Override
public int onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream) throws Http2Exception {
Http2Stream stream = connection.stream(streamId);
HttpMessage msg = getMessage(stream);
if (msg == null) {
throw connectionError(PROTOCOL_ERROR, "Data Frame received for unknown stream id %d", streamId);
}
AtomicInteger dataRead = getDataRead(stream);
final int dataReadableBytes = data.readableBytes();
final int readSoFar = dataRead.getAndAdd(dataReadableBytes);
if (readSoFar > maxContentLength - dataReadableBytes) {
throw connectionError(INTERNAL_ERROR, "Content length exceeded max of %d for stream id %d", maxContentLength, streamId);
}
if (endOfStream) {
// will be released by HttpStreamsHandler
if (dataReadableBytes > 0) {
final DefaultLastHttpContent content = new DefaultLastHttp2Content(data.retain(), stream);
fireChannelRead(ctx, content, stream);
} else {
fireChannelRead(ctx, new DefaultLastHttp2Content(Unpooled.EMPTY_BUFFER, stream), stream);
}
} else {
// will be released by HttpStreamsHandler
final DefaultHttp2Content content = new DefaultHttp2Content(data.retain(), stream);
fireChannelRead(ctx, content, stream);
}
// All bytes have been processed.
return dataReadableBytes + padding;
}
use of io.netty.handler.codec.http2.Http2Stream in project micronaut-core by micronaut-projects.
the class StreamingInboundHttp2ToHttpAdapter method onRstStreamRead.
@Override
public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode) {
Http2Stream stream = connection.stream(streamId);
HttpMessage msg = getMessage(stream);
if (msg != null) {
onRstStreamRead(stream, msg);
}
// discard stream since it has been reset
stream.close();
}
use of io.netty.handler.codec.http2.Http2Stream in project micronaut-core by micronaut-projects.
the class StreamingInboundHttp2ToHttpAdapter method onHeadersRead.
@Override
public void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endOfStream) throws Http2Exception {
Http2Stream stream = connection.stream(streamId);
HttpMessage msg = processHeadersBegin(ctx, stream, headers, true, true);
if (msg != null) {
processHeadersEnd(ctx, stream, msg, endOfStream);
}
}
Aggregations