HttpResponseDecoderTest Class — netty Architecture
Architecture documentation for the HttpResponseDecoderTest class in HttpResponseDecoderTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 90546a8c_51c4_a9dc_b6e8_695d29269596["HttpResponseDecoderTest"] e6d1d68e_8cf8_7114_9792_57dd8d4b0ee1["HttpResponseDecoderTest.java"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|defined in| e6d1d68e_8cf8_7114_9792_57dd8d4b0ee1 74f33848_d63d_306b_647d_78f1ba228fc3["testMaxHeaderSize1()"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|method| 74f33848_d63d_306b_647d_78f1ba228fc3 3bc58c15_2107_cc9a_16f0_be19507abe47["testMaxHeaderSize2()"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|method| 3bc58c15_2107_cc9a_16f0_be19507abe47 826ab2e2_7f78_7506_1345_a9c793d12d3f["testTotalHeaderLimit()"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|method| 826ab2e2_7f78_7506_1345_a9c793d12d3f 805cc2d4_dd80_f5a9_72dd_1a9d0e26292d["testResponseChunked()"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|method| 805cc2d4_dd80_f5a9_72dd_1a9d0e26292d c2f2b7f3_7e5a_52c0_f650_65c5d824ed86["testResponseChunkedWithValidUncommonPatterns()"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|method| c2f2b7f3_7e5a_52c0_f650_65c5d824ed86 bedde236_10c0_3e80_acc6_6aa3f59454f8["testResponseChunkedWithControlChars()"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|method| bedde236_10c0_3e80_acc6_6aa3f59454f8 39992be3_a998_e5e7_6cc1_a77edac46acd["testResponseDisallowPartialChunks()"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|method| 39992be3_a998_e5e7_6cc1_a77edac46acd b40beb75_d915_1036_286d_c59da379c5e7["testResponseChunkedExceedMaxChunkSize()"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|method| b40beb75_d915_1036_286d_c59da379c5e7 1c44ee2c_9d3e_bfaf_420f_50086ce37370["testClosureWithoutContentLength1()"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|method| 1c44ee2c_9d3e_bfaf_420f_50086ce37370 1adad348_9748_1739_c0c7_446d4bac41ba["testClosureWithoutContentLength2()"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|method| 1adad348_9748_1739_c0c7_446d4bac41ba 7370404a_95a9_7a25_4096_fd00ff108156["testPrematureClosureWithChunkedEncoding1()"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|method| 7370404a_95a9_7a25_4096_fd00ff108156 8fcbb9ce_05be_d47e_ef88_8556996cc892["testPrematureClosureWithChunkedEncoding2()"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|method| 8fcbb9ce_05be_d47e_ef88_8556996cc892 0e4fd1ca_77e7_7dd0_cbed_711b295bc5c2["testLastResponseWithEmptyHeaderAndEmptyContent()"] 90546a8c_51c4_a9dc_b6e8_695d29269596 -->|method| 0e4fd1ca_77e7_7dd0_cbed_711b295bc5c2
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java lines 44–1234
public class HttpResponseDecoderTest {
/**
* The size of headers should be calculated correctly even if a single header is split into multiple fragments.
* @see <a href="https://github.com/netty/netty/issues/3445">#3445</a>
*/
@Test
public void testMaxHeaderSize1() {
final int maxHeaderSize = 8192;
final EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder(4096, maxHeaderSize, 8192));
final char[] bytes = new char[maxHeaderSize / 2 - 4];
Arrays.fill(bytes, 'a');
ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.1 200 OK\r\n", CharsetUtil.US_ASCII));
// Write two 4096-byte headers (= 8192 bytes)
ch.writeInbound(Unpooled.copiedBuffer("A:", CharsetUtil.US_ASCII));
ch.writeInbound(Unpooled.copiedBuffer(bytes, CharsetUtil.US_ASCII));
ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.US_ASCII));
assertNull(ch.readInbound());
ch.writeInbound(Unpooled.copiedBuffer("B:", CharsetUtil.US_ASCII));
ch.writeInbound(Unpooled.copiedBuffer(bytes, CharsetUtil.US_ASCII));
ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.US_ASCII));
ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.US_ASCII));
HttpResponse res = ch.readInbound();
assertNull(res.decoderResult().cause());
assertTrue(res.decoderResult().isSuccess());
assertNull(ch.readInbound());
assertTrue(ch.finish());
assertInstanceOf(LastHttpContent.class, ch.readInbound());
}
/**
* Complementary test case of {@link #testMaxHeaderSize1()} When it actually exceeds the maximum, it should fail.
*/
@Test
public void testMaxHeaderSize2() {
final int maxHeaderSize = 8192;
final EmbeddedChannel ch = new EmbeddedChannel(new HttpResponseDecoder(4096, maxHeaderSize, 8192));
final char[] bytes = new char[maxHeaderSize / 2 - 2];
Arrays.fill(bytes, 'a');
ch.writeInbound(Unpooled.copiedBuffer("HTTP/1.1 200 OK\r\n", CharsetUtil.US_ASCII));
// Write a 4096-byte header and a 4097-byte header to test an off-by-one case (= 8193 bytes)
ch.writeInbound(Unpooled.copiedBuffer("A:", CharsetUtil.US_ASCII));
ch.writeInbound(Unpooled.copiedBuffer(bytes, CharsetUtil.US_ASCII));
ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.US_ASCII));
assertNull(ch.readInbound());
ch.writeInbound(Unpooled.copiedBuffer("B: ", CharsetUtil.US_ASCII)); // Note an extra space.
ch.writeInbound(Unpooled.copiedBuffer(bytes, CharsetUtil.US_ASCII));
ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.US_ASCII));
ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.US_ASCII));
HttpResponse res = ch.readInbound();
assertInstanceOf(TooLongHttpHeaderException.class, res.decoderResult().cause());
assertFalse(ch.finish());
assertNull(ch.readInbound());
}
@Test
void testTotalHeaderLimit() throws Exception {
String requestStr = "HTTP/1.1 200 OK\r\n" +
"Server: X\r\n" + // 9 content bytes
"a1: b\r\n" + // + 5 = 14 bytes,
"a2: b\r\n\r\n"; // + 5 = 19 bytes
// Decoding with a max header size of 18 bytes must fail:
EmbeddedChannel channel = new EmbeddedChannel(new HttpResponseDecoder(1024, 18, 1024));
assertTrue(channel.writeInbound(Unpooled.copiedBuffer(requestStr, CharsetUtil.US_ASCII)));
HttpResponse response = channel.readInbound();
assertTrue(response.decoderResult().isFailure());
assertInstanceOf(TooLongHttpHeaderException.class, response.decoderResult().cause());
assertFalse(channel.finish());
// Decoding with a max header size of 19 must pass:
Source
Frequently Asked Questions
What is the HttpResponseDecoderTest class?
HttpResponseDecoderTest is a class in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java.
Where is HttpResponseDecoderTest defined?
HttpResponseDecoderTest is defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java at line 44.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free