HttpServerKeepAliveHandlerTest Class — netty Architecture
Architecture documentation for the HttpServerKeepAliveHandlerTest class in HttpServerKeepAliveHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD be1dd72c_0689_de7f_2cae_50d18d342f5c["HttpServerKeepAliveHandlerTest"] e85b1aca_b6fc_bb52_7ba8_d1c886c3fe9d["HttpServerKeepAliveHandlerTest.java"] be1dd72c_0689_de7f_2cae_50d18d342f5c -->|defined in| e85b1aca_b6fc_bb52_7ba8_d1c886c3fe9d 39af6f29_059f_4319_efdb_f08a2a9fdd0f["setUp()"] be1dd72c_0689_de7f_2cae_50d18d342f5c -->|method| 39af6f29_059f_4319_efdb_f08a2a9fdd0f 3a4d1c4b_554b_5993_e8e2_141087169df5["keepAliveProvider()"] be1dd72c_0689_de7f_2cae_50d18d342f5c -->|method| 3a4d1c4b_554b_5993_e8e2_141087169df5 69511d36_cbb6_3cd3_c5dc_7eab8f1533db["test_KeepAlive()"] be1dd72c_0689_de7f_2cae_50d18d342f5c -->|method| 69511d36_cbb6_3cd3_c5dc_7eab8f1533db ea2adc2d_9ab6_b016_50fc_a2972077905e["connectionCloseProvider()"] be1dd72c_0689_de7f_2cae_50d18d342f5c -->|method| ea2adc2d_9ab6_b016_50fc_a2972077905e 4a3ed746_2618_717d_f666_83698afee601["testConnectionCloseHeaderHandledCorrectly()"] be1dd72c_0689_de7f_2cae_50d18d342f5c -->|method| 4a3ed746_2618_717d_f666_83698afee601 15a8686a_c897_0b73_fdf2_d3a0fee49e7b["testConnectionCloseHeaderHandledCorrectlyForVoidPromise()"] be1dd72c_0689_de7f_2cae_50d18d342f5c -->|method| 15a8686a_c897_0b73_fdf2_d3a0fee49e7b cbd740eb_89cf_330a_c97a_53914a54e207["testPipelineKeepAlive()"] be1dd72c_0689_de7f_2cae_50d18d342f5c -->|method| cbd740eb_89cf_330a_c97a_53914a54e207 4a65f9df_769d_214b_e196_3b450aa1375b["setupMessageLength()"] be1dd72c_0689_de7f_2cae_50d18d342f5c -->|method| 4a65f9df_769d_214b_e196_3b450aa1375b
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/HttpServerKeepAliveHandlerTest.java lines 42–235
public class HttpServerKeepAliveHandlerTest {
private static final String REQUEST_KEEP_ALIVE = "REQUEST_KEEP_ALIVE";
private static final int NOT_SELF_DEFINED_MSG_LENGTH = 0;
private static final int SET_RESPONSE_LENGTH = 1;
private static final int SET_MULTIPART = 2;
private static final int SET_CHUNKED = 4;
private EmbeddedChannel channel;
@BeforeEach
public void setUp() {
channel = new EmbeddedChannel(new HttpServerKeepAliveHandler());
}
static Collection<Object[]> keepAliveProvider() {
return Arrays.asList(new Object[][] {
{ true, HttpVersion.HTTP_1_0, OK, REQUEST_KEEP_ALIVE, SET_RESPONSE_LENGTH, KEEP_ALIVE }, // 0
{ true, HttpVersion.HTTP_1_0, OK, REQUEST_KEEP_ALIVE, SET_MULTIPART, KEEP_ALIVE }, // 1
{ false, HttpVersion.HTTP_1_0, OK, null, SET_RESPONSE_LENGTH, null }, // 2
{ true, HttpVersion.HTTP_1_1, OK, REQUEST_KEEP_ALIVE, SET_RESPONSE_LENGTH, null }, // 3
{ false, HttpVersion.HTTP_1_1, OK, REQUEST_KEEP_ALIVE, SET_RESPONSE_LENGTH, CLOSE }, // 4
{ true, HttpVersion.HTTP_1_1, OK, REQUEST_KEEP_ALIVE, SET_MULTIPART, null }, // 5
{ true, HttpVersion.HTTP_1_1, OK, REQUEST_KEEP_ALIVE, SET_CHUNKED, null }, // 6
{ false, HttpVersion.HTTP_1_1, OK, null, SET_RESPONSE_LENGTH, null }, // 7
{ false, HttpVersion.HTTP_1_0, OK, REQUEST_KEEP_ALIVE, NOT_SELF_DEFINED_MSG_LENGTH, null }, // 8
{ false, HttpVersion.HTTP_1_0, OK, null, NOT_SELF_DEFINED_MSG_LENGTH, null }, // 9
{ false, HttpVersion.HTTP_1_1, OK, REQUEST_KEEP_ALIVE, NOT_SELF_DEFINED_MSG_LENGTH, null }, // 10
{ false, HttpVersion.HTTP_1_1, OK, null, NOT_SELF_DEFINED_MSG_LENGTH, null }, // 11
{ false, HttpVersion.HTTP_1_0, OK, REQUEST_KEEP_ALIVE, SET_RESPONSE_LENGTH, null }, // 12
{ true, HttpVersion.HTTP_1_1, NO_CONTENT, REQUEST_KEEP_ALIVE, NOT_SELF_DEFINED_MSG_LENGTH, null}, // 13
{ false, HttpVersion.HTTP_1_0, NO_CONTENT, null, NOT_SELF_DEFINED_MSG_LENGTH, null} // 14
});
}
@ParameterizedTest
@MethodSource("keepAliveProvider")
public void test_KeepAlive(boolean isKeepAliveResponseExpected, HttpVersion httpVersion,
HttpResponseStatus responseStatus,
String sendKeepAlive, int setSelfDefinedMessageLength,
AsciiString setResponseConnection) throws Exception {
FullHttpRequest request = new DefaultFullHttpRequest(httpVersion, HttpMethod.GET, "/v1/foo/bar");
setKeepAlive(request, REQUEST_KEEP_ALIVE.equals(sendKeepAlive));
HttpResponse response = new DefaultFullHttpResponse(httpVersion, responseStatus);
if (setResponseConnection != null) {
response.headers().set(HttpHeaderNames.CONNECTION, setResponseConnection);
}
setupMessageLength(response, setSelfDefinedMessageLength);
assertTrue(channel.writeInbound(request));
Object requestForwarded = channel.readInbound();
assertEquals(request, requestForwarded);
ReferenceCountUtil.release(requestForwarded);
channel.writeAndFlush(response);
HttpResponse writtenResponse = channel.readOutbound();
assertEquals(isKeepAliveResponseExpected, channel.isOpen(), "channel.isOpen");
assertEquals(isKeepAliveResponseExpected, isKeepAlive(writtenResponse), "response keep-alive");
ReferenceCountUtil.release(writtenResponse);
assertFalse(channel.finishAndReleaseAll());
}
static Collection<Object[]> connectionCloseProvider() {
return Arrays.asList(new Object[][] {
{ HttpVersion.HTTP_1_0, OK, SET_RESPONSE_LENGTH },
{ HttpVersion.HTTP_1_0, OK, SET_MULTIPART },
{ HttpVersion.HTTP_1_0, OK, NOT_SELF_DEFINED_MSG_LENGTH },
{ HttpVersion.HTTP_1_0, NO_CONTENT, NOT_SELF_DEFINED_MSG_LENGTH },
{ HttpVersion.HTTP_1_1, OK, SET_RESPONSE_LENGTH },
{ HttpVersion.HTTP_1_1, OK, SET_MULTIPART },
{ HttpVersion.HTTP_1_1, OK, NOT_SELF_DEFINED_MSG_LENGTH },
{ HttpVersion.HTTP_1_1, OK, SET_CHUNKED },
{ HttpVersion.HTTP_1_1, NO_CONTENT, NOT_SELF_DEFINED_MSG_LENGTH }
});
}
@ParameterizedTest
@MethodSource("connectionCloseProvider")
public void testConnectionCloseHeaderHandledCorrectly(
HttpVersion httpVersion, HttpResponseStatus responseStatus, int setSelfDefinedMessageLength) {
HttpResponse response = new DefaultFullHttpResponse(httpVersion, responseStatus);
response.headers().set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE);
Source
Frequently Asked Questions
What is the HttpServerKeepAliveHandlerTest class?
HttpServerKeepAliveHandlerTest is a class in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpServerKeepAliveHandlerTest.java.
Where is HttpServerKeepAliveHandlerTest defined?
HttpServerKeepAliveHandlerTest is defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpServerKeepAliveHandlerTest.java at line 42.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free