HttpContentDecoderTest Class — netty Architecture
Architecture documentation for the HttpContentDecoderTest class in HttpContentDecoderTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD ea4ec426_b689_ab52_a554_7959aed6c709["HttpContentDecoderTest"] 098622cd_4bc8_6ea8_848b_62c5147b1eba["HttpContentDecoderTest.java"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|defined in| 098622cd_4bc8_6ea8_848b_62c5147b1eba 14854d12_c5f6_6934_ec39_441b8a359663["testBinaryDecompression()"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|method| 14854d12_c5f6_6934_ec39_441b8a359663 1ec7860b_6469_b9a4_5f54_aa51e2515103["testRequestDecompression()"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|method| 1ec7860b_6469_b9a4_5f54_aa51e2515103 3f271494_a1e0_eb6f_6d44_322419727181["testChunkedRequestDecompression()"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|method| 3f271494_a1e0_eb6f_6d44_322419727181 d9f9d6b7_3668_02b5_f8fd_e9221d35f92a["testSnappyResponseDecompression()"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|method| d9f9d6b7_3668_02b5_f8fd_e9221d35f92a 4a1b7c3b_a66c_8171_f9d8_2eb6ccda0e1e["testResponseDecompression()"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|method| 4a1b7c3b_a66c_8171_f9d8_2eb6ccda0e1e 5e39f49b_062b_9d49_5805_1a2c160c391a["testResponseBrotliDecompression()"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|method| 5e39f49b_062b_9d49_5805_1a2c160c391a b9d0cd19_cd58_ecba_df1f_52e9cb6f393b["testResponseChunksBrotliDecompression()"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|method| b9d0cd19_cd58_ecba_df1f_52e9cb6f393b 0ab73bef_6ed7_a8e0_f505_22a5c279fdff["testResponseZstdDecompression()"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|method| 0ab73bef_6ed7_a8e0_f505_22a5c279fdff 0a45d381_1167_b359_ed23_c5d38614b9bf["testResponseChunksZstdDecompression()"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|method| 0a45d381_1167_b359_ed23_c5d38614b9bf 4066bce7_807b_bd8a_2107_f3aa628b5a0a["testExpectContinueResponse1()"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|method| 4066bce7_807b_bd8a_2107_f3aa628b5a0a 751606fd_ca7f_90e8_3ac4_8f402e9a4830["testExpectContinueResponse2()"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|method| 751606fd_ca7f_90e8_3ac4_8f402e9a4830 d5f347a2_2905_fec2_ec52_9069dbc1a711["testExpectContinueResponse3()"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|method| d5f347a2_2905_fec2_ec52_9069dbc1a711 1db27e45_693d_ff6f_7a00_2cd1f58d630c["testExpectContinueResponse4()"] ea4ec426_b689_ab52_a554_7959aed6c709 -->|method| 1db27e45_693d_ff6f_7a00_2cd1f58d630c
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java lines 51–942
public class HttpContentDecoderTest {
private static final String HELLO_WORLD = "hello, world";
private static final byte[] GZ_HELLO_WORLD = {
31, -117, 8, 8, 12, 3, -74, 84, 0, 3, 50, 0, -53, 72, -51, -55, -55,
-41, 81, 40, -49, 47, -54, 73, 1, 0, 58, 114, -85, -1, 12, 0, 0, 0
};
private static final byte[] SNAPPY_HELLO_WORLD = {
-1, 6, 0, 0, 115, 78, 97, 80, 112, 89, 1, 16, 0, 0, 11, -66, -63,
-22, 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100
};
private static final String SAMPLE_STRING = "Hello, I am Meow!. A small kitten. :)" +
"I sleep all day, and meow all night.";
private static final byte[] SAMPLE_BZ_BYTES = new byte[]{27, 72, 0, 0, -60, -102, 91, -86, 103, 20,
-28, -23, 54, -101, 11, -106, -16, -32, -95, -61, -37, 94, -16, 97, -40, -93, -56, 18, 21, 86,
-110, 82, -41, 102, -89, 20, 11, 10, -68, -31, 96, -116, -55, -80, -31, -91, 96, -64, 83, 51,
-39, 13, -21, 92, -16, -119, 124, -31, 18, 78, -1, 91, 82, 105, -116, -95, -22, -11, -70, -45, 0};
private static final byte[] SAMPLE_ZSTD_BYTES = new byte[]{40, -75, 47, -3, 32, 73, 45, 2, 0, 2, -124, 14,
22, -112, -75, 109, 11, -112, 113, 101, -65, 53, 59, -25, -51, -51, -78, 40, -120, -69, -32, 110, -7,
-81, 28, -90, -112, 3, -23, -38, -89, -113, -98, 75, -32, -114, 1, 63, 38, 27, 97, -80, -23, -107, 66,
-119, 17, 47, -109, 9, 91, -80, -10, -122, -13, 108, 92, 22, -15, 69, 2, 0, 53, -27, 55, -125, 89, 6};
@Test
public void testBinaryDecompression() throws Exception {
// baseline test: zlib library and test helpers work correctly.
byte[] helloWorld = gzDecompress(GZ_HELLO_WORLD);
assertEquals(HELLO_WORLD.length(), helloWorld.length);
assertEquals(HELLO_WORLD, new String(helloWorld, CharsetUtil.US_ASCII));
String fullCycleTest = "full cycle test";
byte[] compressed = gzCompress(fullCycleTest.getBytes(CharsetUtil.US_ASCII));
byte[] decompressed = gzDecompress(compressed);
assertEquals(decompressed.length, fullCycleTest.length());
assertEquals(fullCycleTest, new String(decompressed, CharsetUtil.US_ASCII));
}
@Test
public void testRequestDecompression() {
// baseline test: request decoder, content decompressor && request aggregator work as expected
HttpRequestDecoder decoder = new HttpRequestDecoder();
HttpContentDecoder decompressor = new HttpContentDecompressor(0);
HttpObjectAggregator aggregator = new HttpObjectAggregator(1024);
EmbeddedChannel channel = new EmbeddedChannel(decoder, decompressor, aggregator);
String headers = "POST / HTTP/1.1\r\n" +
"Content-Length: " + GZ_HELLO_WORLD.length + "\r\n" +
"Content-Encoding: gzip\r\n" +
"\r\n";
ByteBuf buf = Unpooled.copiedBuffer(headers.getBytes(CharsetUtil.US_ASCII), GZ_HELLO_WORLD);
assertTrue(channel.writeInbound(buf));
Object o = channel.readInbound();
assertInstanceOf(FullHttpRequest.class, o);
FullHttpRequest req = (FullHttpRequest) o;
assertEquals(HELLO_WORLD.length(), req.headers().getInt(HttpHeaderNames.CONTENT_LENGTH).intValue());
assertEquals(HELLO_WORLD, req.content().toString(CharsetUtil.US_ASCII));
req.release();
assertHasInboundMessages(channel, false);
assertHasOutboundMessages(channel, false);
assertFalse(channel.finish()); // assert that no messages are left in channel
}
@Test
public void testChunkedRequestDecompression() {
HttpResponseDecoder decoder = new HttpResponseDecoder();
HttpContentDecoder decompressor = new HttpContentDecompressor(0);
EmbeddedChannel channel = new EmbeddedChannel(decoder, decompressor, null);
String headers = "HTTP/1.1 200 OK\r\n"
+ "Transfer-Encoding: chunked\r\n"
+ "Trailer: My-Trailer\r\n"
+ "Content-Encoding: gzip\r\n\r\n";
channel.writeInbound(Unpooled.copiedBuffer(headers.getBytes(CharsetUtil.US_ASCII)));
String chunkLength = Integer.toHexString(GZ_HELLO_WORLD.length);
assertTrue(channel.writeInbound(Unpooled.copiedBuffer(chunkLength + "\r\n", CharsetUtil.US_ASCII)));
assertTrue(channel.writeInbound(Unpooled.copiedBuffer(GZ_HELLO_WORLD)));
assertTrue(channel.writeInbound(Unpooled.copiedBuffer("\r\n".getBytes(CharsetUtil.US_ASCII))));
Source
Frequently Asked Questions
What is the HttpContentDecoderTest class?
HttpContentDecoderTest is a class in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java.
Where is HttpContentDecoderTest defined?
HttpContentDecoderTest is defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpContentDecoderTest.java at line 51.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free