testResponseDisallowPartialChunks() — netty Function Reference
Architecture documentation for the testResponseDisallowPartialChunks() function in HttpResponseDecoderTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 39992be3_a998_e5e7_6cc1_a77edac46acd["testResponseDisallowPartialChunks()"] 90546a8c_51c4_a9dc_b6e8_695d29269596["HttpResponseDecoderTest"] 39992be3_a998_e5e7_6cc1_a77edac46acd -->|defined in| 90546a8c_51c4_a9dc_b6e8_695d29269596 style 39992be3_a998_e5e7_6cc1_a77edac46acd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java lines 291–341
@Test
public void testResponseDisallowPartialChunks() {
HttpResponseDecoder decoder = new HttpResponseDecoder(
HttpObjectDecoder.DEFAULT_MAX_INITIAL_LINE_LENGTH,
HttpObjectDecoder.DEFAULT_MAX_HEADER_SIZE,
HttpObjectDecoder.DEFAULT_MAX_CHUNK_SIZE,
HttpObjectDecoder.DEFAULT_VALIDATE_HEADERS,
HttpObjectDecoder.DEFAULT_INITIAL_BUFFER_SIZE,
HttpObjectDecoder.DEFAULT_ALLOW_DUPLICATE_CONTENT_LENGTHS,
false);
EmbeddedChannel ch = new EmbeddedChannel(decoder);
String headers = "HTTP/1.1 200 OK\r\n"
+ "Transfer-Encoding: chunked\r\n"
+ "\r\n";
assertTrue(ch.writeInbound(Unpooled.copiedBuffer(headers, CharsetUtil.US_ASCII)));
HttpResponse res = ch.readInbound();
assertSame(HttpVersion.HTTP_1_1, res.protocolVersion());
assertEquals(HttpResponseStatus.OK, res.status());
byte[] chunkBytes = new byte[10];
Random random = new Random();
random.nextBytes(chunkBytes);
final ByteBuf chunk = ch.alloc().buffer().writeBytes(chunkBytes);
final int chunkSize = chunk.readableBytes();
ByteBuf partialChunk1 = chunk.retainedSlice(0, 5);
ByteBuf partialChunk2 = chunk.retainedSlice(5, 5);
assertFalse(ch.writeInbound(Unpooled.copiedBuffer(Integer.toHexString(chunkSize)
+ "\r\n", CharsetUtil.US_ASCII)));
assertFalse(ch.writeInbound(partialChunk1));
assertTrue(ch.writeInbound(partialChunk2));
HttpContent content = ch.readInbound();
assertEquals(chunk, content.content());
content.release();
chunk.release();
assertFalse(ch.writeInbound(Unpooled.copiedBuffer("\r\n", CharsetUtil.US_ASCII)));
// Write the last chunk.
assertTrue(ch.writeInbound(Unpooled.copiedBuffer("0\r\n\r\n", CharsetUtil.US_ASCII)));
// Ensure the last chunk was decoded.
HttpContent lastContent = ch.readInbound();
assertFalse(lastContent.content().isReadable());
lastContent.release();
assertFalse(ch.finish());
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testResponseDisallowPartialChunks() do?
testResponseDisallowPartialChunks() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java.
Where is testResponseDisallowPartialChunks() defined?
testResponseDisallowPartialChunks() is defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpResponseDecoderTest.java at line 291.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free