InboundHttpToHttp2Adapter Class — netty Architecture
Architecture documentation for the InboundHttpToHttp2Adapter class in InboundHttpToHttp2Adapter.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD b0a0f922_5d85_6902_3570_10d070eb200a["InboundHttpToHttp2Adapter"] 74473f47_2077_6b87_9081_5d628948eb26["InboundHttpToHttp2Adapter.java"] b0a0f922_5d85_6902_3570_10d070eb200a -->|defined in| 74473f47_2077_6b87_9081_5d628948eb26 a3e897ed_9de4_cd73_95ba_b3119eae29e0["InboundHttpToHttp2Adapter()"] b0a0f922_5d85_6902_3570_10d070eb200a -->|method| a3e897ed_9de4_cd73_95ba_b3119eae29e0 4f219723_6c91_535c_23e8_6c1aa312114a["getStreamId()"] b0a0f922_5d85_6902_3570_10d070eb200a -->|method| 4f219723_6c91_535c_23e8_6c1aa312114a 113c2760_d8ce_372d_7ab9_99f2b71d4333["channelRead()"] b0a0f922_5d85_6902_3570_10d070eb200a -->|method| 113c2760_d8ce_372d_7ab9_99f2b71d4333 3f8e31aa_60e4_8d88_3891_2547a3b5f313["handle()"] b0a0f922_5d85_6902_3570_10d070eb200a -->|method| 3f8e31aa_60e4_8d88_3891_2547a3b5f313
Relationship Graph
Source Code
codec-http2/src/main/java/io/netty/handler/codec/http2/InboundHttpToHttp2Adapter.java lines 27–79
public class InboundHttpToHttp2Adapter extends ChannelInboundHandlerAdapter {
private final Http2Connection connection;
private final Http2FrameListener listener;
public InboundHttpToHttp2Adapter(Http2Connection connection, Http2FrameListener listener) {
this.connection = connection;
this.listener = listener;
}
private static int getStreamId(Http2Connection connection, HttpHeaders httpHeaders) {
return httpHeaders.getInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(),
connection.remote().incrementAndGetNextStreamId());
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof FullHttpMessage) {
handle(ctx, connection, listener, (FullHttpMessage) msg);
} else {
super.channelRead(ctx, msg);
}
}
// 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.
static void handle(ChannelHandlerContext ctx, Http2Connection connection,
Http2FrameListener listener, FullHttpMessage message) throws Http2Exception {
try {
int streamId = getStreamId(connection, message.headers());
Http2Stream stream = connection.stream(streamId);
if (stream == null) {
stream = connection.remote().createStream(streamId, false);
}
message.headers().set(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), HttpScheme.HTTP.name());
Http2Headers messageHeaders = HttpConversionUtil.toHttp2Headers(message, true);
boolean hasContent = message.content().isReadable();
boolean hasTrailers = !message.trailingHeaders().isEmpty();
listener.onHeadersRead(
ctx, streamId, messageHeaders, 0, !(hasContent || hasTrailers));
if (hasContent) {
listener.onDataRead(ctx, streamId, message.content(), 0, !hasTrailers);
}
if (hasTrailers) {
Http2Headers headers = HttpConversionUtil.toHttp2Headers(message.trailingHeaders(), true);
listener.onHeadersRead(ctx, streamId, headers, 0, true);
}
stream.closeRemoteSide();
} finally {
message.release();
}
}
}
Source
Frequently Asked Questions
What is the InboundHttpToHttp2Adapter class?
InboundHttpToHttp2Adapter is a class in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/InboundHttpToHttp2Adapter.java.
Where is InboundHttpToHttp2Adapter defined?
InboundHttpToHttp2Adapter is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/InboundHttpToHttp2Adapter.java at line 27.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free