testEncodeCombination() — netty Function Reference
Architecture documentation for the testEncodeCombination() function in Http3FrameToHttpObjectCodecTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 5f881470_0e46_23fd_ac54_c34ed9e9a00f["testEncodeCombination()"] 0358625f_2420_3fbe_f6d7_5ee2577ca675["Http3FrameToHttpObjectCodecTest"] 5f881470_0e46_23fd_ac54_c34ed9e9a00f -->|defined in| 0358625f_2420_3fbe_f6d7_5ee2577ca675 style 5f881470_0e46_23fd_ac54_c34ed9e9a00f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http3/src/test/java/io/netty/handler/codec/http3/Http3FrameToHttpObjectCodecTest.java lines 737–830
@ParameterizedTest(name = "headers: {0}, last: {1}, nonEmptyContent: {2}, hasTrailers: {3}, voidPromise: {4}")
@ArgumentsSource(value = EncodeCombinationsArgumentsProvider.class)
public void testEncodeCombination(
boolean headers,
boolean last,
boolean nonEmptyContent,
boolean hasTrailers,
boolean voidPromise
) {
ByteBuf content = nonEmptyContent ? Unpooled.wrappedBuffer(new byte[1]) : Unpooled.EMPTY_BUFFER;
HttpHeaders trailers = new DefaultHttpHeaders();
if (hasTrailers) {
trailers.add("foo", "bar");
}
HttpObject msg;
if (headers) {
if (last) {
msg = new DefaultFullHttpRequest(
HttpVersion.HTTP_1_1, HttpMethod.POST, "/foo", content, new DefaultHttpHeaders(), trailers);
} else {
if (hasTrailers || nonEmptyContent) {
// not supported by the netty HTTP/1 model
content.release();
return;
}
msg = new DefaultHttpRequest(
HttpVersion.HTTP_1_1, HttpMethod.POST, "/foo", new DefaultHttpHeaders());
}
} else {
if (last) {
msg = new DefaultLastHttpContent(content, trailers);
} else {
if (hasTrailers) {
// makes no sense
content.release();
return;
}
msg = new DefaultHttpContent(content);
}
}
List<ChannelPromise> framePromises = new ArrayList<>();
EmbeddedQuicStreamChannel ch = new EmbeddedQuicStreamChannel(
new ChannelOutboundHandlerAdapter() {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
framePromises.add(promise);
ctx.write(msg, ctx.voidPromise());
}
},
new Http3FrameToHttpObjectCodec(false)
);
ChannelFuture fullPromise = ch.writeOneOutbound(msg, voidPromise ? ch.voidPromise() : ch.newPromise());
ch.flushOutbound();
if (headers) {
Http3HeadersFrame headersFrame = ch.readOutbound();
assertThat(headersFrame.headers().scheme().toString(), is("https"));
assertThat(headersFrame.headers().method().toString(), is("POST"));
assertThat(headersFrame.headers().path().toString(), is("/foo"));
}
if (nonEmptyContent) {
Http3DataFrame dataFrame = ch.readOutbound();
assertThat(dataFrame.content().readableBytes(), is(1));
dataFrame.release();
}
if (hasTrailers) {
Http3HeadersFrame trailersFrame = ch.readOutbound();
assertThat(trailersFrame.headers().get("foo"), is("bar"));
} else if (!nonEmptyContent && !headers) {
Http3DataFrame dataFrame = ch.readOutbound();
assertThat(dataFrame.content().readableBytes(), is(0));
dataFrame.release();
}
if (!voidPromise) {
assertFalse(fullPromise.isDone());
}
assertFalse(ch.isOutputShutdown());
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does testEncodeCombination() do?
testEncodeCombination() is a function in the netty codebase, defined in codec-http3/src/test/java/io/netty/handler/codec/http3/Http3FrameToHttpObjectCodecTest.java.
Where is testEncodeCombination() defined?
testEncodeCombination() is defined in codec-http3/src/test/java/io/netty/handler/codec/http3/Http3FrameToHttpObjectCodecTest.java at line 737.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free