testSelectiveResponseAggregation() — netty Function Reference
Architecture documentation for the testSelectiveResponseAggregation() function in HttpObjectAggregatorTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD f808a97e_9fbd_2551_2182_29919bcd4a11["testSelectiveResponseAggregation()"] 32ca569a_2b67_1114_bbc8_cbf703c91b95["HttpObjectAggregatorTest"] f808a97e_9fbd_2551_2182_29919bcd4a11 -->|defined in| 32ca569a_2b67_1114_bbc8_cbf703c91b95 style f808a97e_9fbd_2551_2182_29919bcd4a11 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-http/src/test/java/io/netty/handler/codec/http/HttpObjectAggregatorTest.java lines 686–744
@Test
public void testSelectiveResponseAggregation() {
HttpObjectAggregator myTextAggregator = new HttpObjectAggregator(1024 * 1024) {
@Override
protected boolean isStartMessage(HttpObject msg) throws Exception {
if (msg instanceof HttpResponse) {
HttpResponse response = (HttpResponse) msg;
HttpHeaders headers = response.headers();
String contentType = headers.get(HttpHeaderNames.CONTENT_TYPE);
if (AsciiString.contentEqualsIgnoreCase(contentType, HttpHeaderValues.TEXT_PLAIN)) {
return true;
}
}
return false;
}
};
EmbeddedChannel channel = new EmbeddedChannel(myTextAggregator);
try {
// Aggregate: text/plain
HttpResponse response1 = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
HttpContent content1 = new DefaultHttpContent(Unpooled.copiedBuffer("Hello, World!", CharsetUtil.UTF_8));
response1.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN);
assertTrue(channel.writeInbound(response1, content1, LastHttpContent.EMPTY_LAST_CONTENT));
// Getting an aggregated response out
Object msg1 = channel.readInbound();
try {
assertTrue(msg1 instanceof FullHttpResponse);
} finally {
ReferenceCountUtil.release(msg1);
}
// Don't aggregate: application/json
HttpResponse response2 = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
HttpContent content2 = new DefaultHttpContent(Unpooled.copiedBuffer("{key: 'value'}", CharsetUtil.UTF_8));
response2.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON);
try {
assertTrue(channel.writeInbound(response2, content2, LastHttpContent.EMPTY_LAST_CONTENT));
// Getting the same response objects out
assertSame(response2, channel.readInbound());
assertSame(content2, channel.readInbound());
assertSame(LastHttpContent.EMPTY_LAST_CONTENT, channel.readInbound());
} finally {
ReferenceCountUtil.release(response2);
ReferenceCountUtil.release(content2);
}
assertFalse(channel.finish());
} finally {
channel.close();
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testSelectiveResponseAggregation() do?
testSelectiveResponseAggregation() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpObjectAggregatorTest.java.
Where is testSelectiveResponseAggregation() defined?
testSelectiveResponseAggregation() is defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpObjectAggregatorTest.java at line 686.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free