Home / Class/ HttpClientCodecTest Class — netty Architecture

HttpClientCodecTest Class — netty Architecture

Architecture documentation for the HttpClientCodecTest class in HttpClientCodecTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  c395f8e2_08a9_4e0c_820e_5851189d51c7["HttpClientCodecTest"]
  5ba344f6_8fc6_3fe1_4b5e_2903a4af1452["HttpClientCodecTest.java"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|defined in| 5ba344f6_8fc6_3fe1_4b5e_2903a4af1452
  0d566c9a_1a29_a39c_4755_f129a2cf1388["testConnectWithResponseContent()"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|method| 0d566c9a_1a29_a39c_4755_f129a2cf1388
  44273dc7_cb69_a752_aed5_8ef2f356d00f["testFailsNotOnRequestResponseChunked()"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|method| 44273dc7_cb69_a752_aed5_8ef2f356d00f
  1ebf3808_554f_6bd8_4c8e_7f7389ebfde2["testFailsOnMissingResponse()"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|method| 1ebf3808_554f_6bd8_4c8e_7f7389ebfde2
  d6cadc08_4439_7ec9_73d0_ab75e51a5938["testFailsOnIncompleteChunkedResponse()"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|method| d6cadc08_4439_7ec9_73d0_ab75e51a5938
  327ec659_e29e_87dc_59e2_519c04baf487["testServerCloseSocketInputProvidesData()"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|method| 327ec659_e29e_87dc_59e2_519c04baf487
  a824e494_0d77_e8a5_bd8a_28fa3395b44c["testContinueParsingAfterConnect()"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|method| a824e494_0d77_e8a5_bd8a_28fa3395b44c
  a3db3014_4bdd_3be6_35d8_af2b2797eb45["testPassThroughAfterConnect()"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|method| a3db3014_4bdd_3be6_35d8_af2b2797eb45
  6c488629_037c_2535_c3c8_3c1f70b89474["testAfterConnect()"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|method| 6c488629_037c_2535_c3c8_3c1f70b89474
  5485adc8_072b_0345_d50b_1dc2bdbcee72["sendRequestAndReadResponse()"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|method| 5485adc8_072b_0345_d50b_1dc2bdbcee72
  cc9a8227_cd53_e794_15ee_882aa10dd6be["testDecodesFinalResponseAfterSwitchingProtocols()"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|method| cc9a8227_cd53_e794_15ee_882aa10dd6be
  29f7fe5f_6823_e031_39ef_00ec0207f917["testWebSocket00Response()"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|method| 29f7fe5f_6823_e031_39ef_00ec0207f917
  1501a870_b0d5_c066_8a8f_0ffdf6e1c4d7["testWebDavResponse()"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|method| 1501a870_b0d5_c066_8a8f_0ffdf6e1c4d7
  8338a170_1f39_203d_05b7_e23da6fdbc85["testInformationalResponseKeepsPairsInSync()"]
  c395f8e2_08a9_4e0c_820e_5851189d51c7 -->|method| 8338a170_1f39_203d_05b7_e23da6fdbc85

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java lines 55–435

public class HttpClientCodecTest {

    private static final String EMPTY_RESPONSE = "HTTP/1.0 200 OK\r\nContent-Length: 0\r\n\r\n";
    private static final String RESPONSE = "HTTP/1.0 200 OK\r\n" + "Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n" +
            "Content-Type: text/html\r\n" + "Content-Length: 28\r\n" + "\r\n"
            + "<html><body></body></html>\r\n";
    private static final String INCOMPLETE_CHUNKED_RESPONSE = "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain\r\n" +
            "Transfer-Encoding: chunked\r\n" + "\r\n" +
            "5\r\n" + "first\r\n" + "6\r\n" + "second\r\n" + "0\r\n";
    private static final String CHUNKED_RESPONSE = INCOMPLETE_CHUNKED_RESPONSE + "\r\n";

    @Test
    public void testConnectWithResponseContent() {
        HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
        EmbeddedChannel ch = new EmbeddedChannel(codec);

        sendRequestAndReadResponse(ch, HttpMethod.CONNECT, RESPONSE);
        ch.finish();
    }

    @Test
    public void testFailsNotOnRequestResponseChunked() {
        HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
        EmbeddedChannel ch = new EmbeddedChannel(codec);

        sendRequestAndReadResponse(ch, HttpMethod.GET, CHUNKED_RESPONSE);
        ch.finish();
    }

    @Test
    public void testFailsOnMissingResponse() {
        HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
        EmbeddedChannel ch = new EmbeddedChannel(codec);

        assertTrue(ch.writeOutbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
                "http://localhost/")));
        ByteBuf buffer = ch.readOutbound();
        assertNotNull(buffer);
        buffer.release();
        try {
            ch.finish();
            fail();
        } catch (CodecException e) {
            assertTrue(e instanceof PrematureChannelClosureException);
        }
    }

    @Test
    public void testFailsOnIncompleteChunkedResponse() {
        HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
        EmbeddedChannel ch = new EmbeddedChannel(codec);

        ch.writeOutbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/"));
        ByteBuf buffer = ch.readOutbound();
        assertNotNull(buffer);
        buffer.release();
        assertNull(ch.readInbound());
        ch.writeInbound(Unpooled.copiedBuffer(INCOMPLETE_CHUNKED_RESPONSE, CharsetUtil.ISO_8859_1));
        assertInstanceOf(HttpResponse.class, ch.readInbound());
        ((HttpContent) ch.readInbound()).release(); // Chunk 'first'
        ((HttpContent) ch.readInbound()).release(); // Chunk 'second'
        assertNull(ch.readInbound());

        try {
            ch.finish();
            fail();
        } catch (CodecException e) {
            assertTrue(e instanceof PrematureChannelClosureException);
        }
    }

    @Test
    public void testServerCloseSocketInputProvidesData() throws InterruptedException {
        ServerBootstrap sb = new ServerBootstrap();
        Bootstrap cb = new Bootstrap();
        final CountDownLatch serverChannelLatch = new CountDownLatch(1);
        final CountDownLatch responseReceivedLatch = new CountDownLatch(1);
        try {
            sb.group(new MultiThreadIoEventLoopGroup(2, NioIoHandler.newFactory()));
            sb.channel(NioServerSocketChannel.class);
            sb.childHandler(new ChannelInitializer<Channel>() {

Frequently Asked Questions

What is the HttpClientCodecTest class?
HttpClientCodecTest is a class in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java.
Where is HttpClientCodecTest defined?
HttpClientCodecTest is defined in codec-http/src/test/java/io/netty/handler/codec/http/HttpClientCodecTest.java at line 55.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free