HttpServerCodecTest Class — netty Architecture
Architecture documentation for the HttpServerCodecTest class in HttpServerCodecTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD b6cdc8d3_b482_5921_941d_6401914d1c4f["HttpServerCodecTest"] 764ea1b9_e7b2_057b_654c_9bee41e54212["HttpServerCodecTest.java"] b6cdc8d3_b482_5921_941d_6401914d1c4f -->|defined in| 764ea1b9_e7b2_057b_654c_9bee41e54212 abdadbbe_406f_1f8c_7839_ccce79f4a683["testUnfinishedChunkedHttpRequestIsLastFlag()"] b6cdc8d3_b482_5921_941d_6401914d1c4f -->|method| abdadbbe_406f_1f8c_7839_ccce79f4a683 bf5e8220_1666_227f_772a_4d472ea73757["test100Continue()"] b6cdc8d3_b482_5921_941d_6401914d1c4f -->|method| bf5e8220_1666_227f_772a_4d472ea73757 0a381bcf_9220_817a_2571_a07ccae6bc3c["testChunkedHeadResponse()"] b6cdc8d3_b482_5921_941d_6401914d1c4f -->|method| 0a381bcf_9220_817a_2571_a07ccae6bc3c 018891a0_9749_9693_27c2_b409b748bf4e["testChunkedHeadFullHttpResponse()"] b6cdc8d3_b482_5921_941d_6401914d1c4f -->|method| 018891a0_9749_9693_27c2_b409b748bf4e c2bdeff4_bc41_a2e0_e357_c5b11af685c5["ByteBuf()"] b6cdc8d3_b482_5921_941d_6401914d1c4f -->|method| c2bdeff4_bc41_a2e0_e357_c5b11af685c5
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/HttpServerCodecTest.java lines 30–184
public class HttpServerCodecTest {
/**
* Testcase for https://github.com/netty/netty/issues/433
*/
@Test
public void testUnfinishedChunkedHttpRequestIsLastFlag() throws Exception {
int maxChunkSize = 2000;
HttpServerCodec httpServerCodec = new HttpServerCodec(1000, 1000, maxChunkSize);
EmbeddedChannel decoderEmbedder = new EmbeddedChannel(httpServerCodec);
int totalContentLength = maxChunkSize * 5;
decoderEmbedder.writeInbound(Unpooled.copiedBuffer(
"PUT /test HTTP/1.1\r\n" +
"Content-Length: " + totalContentLength + "\r\n" +
"\r\n", CharsetUtil.UTF_8));
int offeredContentLength = (int) (maxChunkSize * 2.5);
decoderEmbedder.writeInbound(prepareDataChunk(offeredContentLength));
decoderEmbedder.finish();
HttpMessage httpMessage = decoderEmbedder.readInbound();
assertNotNull(httpMessage);
boolean empty = true;
int totalBytesPolled = 0;
for (;;) {
HttpContent httpChunk = decoderEmbedder.readInbound();
if (httpChunk == null) {
break;
}
empty = false;
totalBytesPolled += httpChunk.content().readableBytes();
assertFalse(httpChunk instanceof LastHttpContent);
httpChunk.release();
}
assertFalse(empty);
assertEquals(offeredContentLength, totalBytesPolled);
}
@Test
public void test100Continue() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new HttpServerCodec(), new HttpObjectAggregator(1024));
// Send the request headers.
ch.writeInbound(Unpooled.copiedBuffer(
"PUT /upload-large HTTP/1.1\r\n" +
"Expect: 100-continue\r\n" +
"Content-Length: 1\r\n\r\n", CharsetUtil.UTF_8));
// Ensure the aggregator generates nothing.
assertNull(ch.readInbound());
// Ensure the aggregator writes a 100 Continue response.
ByteBuf continueResponse = ch.readOutbound();
assertEquals("HTTP/1.1 100 Continue\r\n\r\n", continueResponse.toString(CharsetUtil.UTF_8));
continueResponse.release();
// But nothing more.
assertNull(ch.readOutbound());
// Send the content of the request.
ch.writeInbound(Unpooled.wrappedBuffer(new byte[] { 42 }));
// Ensure the aggregator generates a full request.
FullHttpRequest req = ch.readInbound();
assertEquals("1", req.headers().get(HttpHeaderNames.CONTENT_LENGTH));
assertEquals(1, req.content().readableBytes());
assertEquals((byte) 42, req.content().readByte());
req.release();
// But nothing more.
assertNull(ch.readInbound());
// Send the actual response.
FullHttpResponse res = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CREATED);
res.content().writeBytes("OK".getBytes(CharsetUtil.UTF_8));
res.headers().setInt(HttpHeaderNames.CONTENT_LENGTH, 2);
ch.writeOutbound(res);
Source
Frequently Asked Questions
What is the HttpServerCodecTest class?
HttpServerCodecTest is a class in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpServerCodecTest.java.
Where is HttpServerCodecTest defined?
HttpServerCodecTest is defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpServerCodecTest.java at line 30.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free