Home / Class/ HttpContentCompressorTest Class — netty Architecture

HttpContentCompressorTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  32ab04b0_6c83_d4f7_6483_fd304f908331["HttpContentCompressorTest"]
  80b9a983_b590_6c70_45c8_cd2918f8acfd["HttpContentCompressorTest.java"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|defined in| 80b9a983_b590_6c70_45c8_cd2918f8acfd
  4093323e_4625_f1a9_f77a_e73c7f67c319["testGetTargetContentEncoding()"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|method| 4093323e_4625_f1a9_f77a_e73c7f67c319
  ac9bf157_55d6_85f8_4751_4086eaf29b39["testDetermineEncoding()"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|method| ac9bf157_55d6_85f8_4751_4086eaf29b39
  a0c6bdfa_9ab1_b97b_c252_b1958f89a1f7["testSplitContent()"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|method| a0c6bdfa_9ab1_b97b_c252_b1958f89a1f7
  33d61232_3242_8775_7fe0_d3daa425ef5c["testChunkedContent()"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|method| 33d61232_3242_8775_7fe0_d3daa425ef5c
  4a59ce6e_fb08_74f2_2002_2b895b4a0b88["testChunkedContentWithAssembledResponse()"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|method| 4a59ce6e_fb08_74f2_2002_2b895b4a0b88
  4312bdb1_0bde_bc71_63f0_9820e32fd415["testChunkedContentWithAssembledResponseIdentityEncoding()"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|method| 4312bdb1_0bde_bc71_63f0_9820e32fd415
  f799dce5_0fa7_89a5_e285_2f5c1a60dd0c["testContentWithAssembledResponseIdentityEncodingHttp10()"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|method| f799dce5_0fa7_89a5_e285_2f5c1a60dd0c
  6ed673e6_989a_48f5_c1bc_d2bcd90e75ae["testChunkedContentWithTrailingHeader()"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|method| 6ed673e6_989a_48f5_c1bc_d2bcd90e75ae
  e132a37e_f108_a95e_9496_c6e09a7e5beb["testFullContentWithContentLength()"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|method| e132a37e_f108_a95e_9496_c6e09a7e5beb
  6cd41577_9a9b_c349_babb_f7eb209e86f1["testFullContent()"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|method| 6cd41577_9a9b_c349_babb_f7eb209e86f1
  24c68591_6b2f_9742_9e05_ac6ce1a5e175["testExecutorPreserveOrdering()"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|method| 24c68591_6b2f_9742_9e05_ac6ce1a5e175
  088c32ee_5b99_1d6b_8bee_8b4d40025262["testEmptySplitContent()"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|method| 088c32ee_5b99_1d6b_8bee_8b4d40025262
  9331a53a_549e_1ae8_5f6e_64f7f29958cf["testEmptyFullContent()"]
  32ab04b0_6c83_d4f7_6483_fd304f908331 -->|method| 9331a53a_549e_1ae8_5f6e_64f7f29958cf

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/HttpContentCompressorTest.java lines 68–1103

public class HttpContentCompressorTest {

    @Test
    public void testGetTargetContentEncoding() throws Exception {
        HttpContentCompressor compressor = new HttpContentCompressor();

        String[] tests = {
            // Accept-Encoding -> Content-Encoding
            "", null,
            "*", "gzip",
            "*;q=0.0", null,
            "gzip", "gzip",
            "compress, gzip;q=0.5", "gzip",
            "gzip; q=0.5, identity", "gzip",
            "gzip ; q=0.1", "gzip",
            "gzip; q=0, deflate", "deflate",
            " deflate ; q=0 , *;q=0.5", "gzip",
        };
        for (int i = 0; i < tests.length; i += 2) {
            String acceptEncoding = tests[i];
            String contentEncoding = tests[i + 1];
            ZlibWrapper targetWrapper = compressor.determineWrapper(acceptEncoding);
            String targetEncoding = null;
            if (targetWrapper != null) {
                switch (targetWrapper) {
                case GZIP:
                    targetEncoding = "gzip";
                    break;
                case ZLIB:
                    targetEncoding = "deflate";
                    break;
                default:
                    fail();
                }
            }
            assertEquals(contentEncoding, targetEncoding);
        }
    }

    @Test
    public void testDetermineEncoding() throws Exception {
        HttpContentCompressor compressor = new HttpContentCompressor((CompressionOptions[]) null);

        String[] tests = {
                // Accept-Encoding -> Content-Encoding
                "", null,
                ",", null,
                "identity", null,
                "unknown", null,
                "*", "br",
                "br", "br",
                "br ; q=0.1", "br",
                "unknown, br", "br",
                "br, gzip", "br",
                "gzip, br", "br",
                "identity, br", "br",
                "gzip", "gzip",
                "gzip ; q=0.1", "gzip",
        };
        for (int i = 0; i < tests.length; i += 2) {
            final String acceptEncoding = tests[i];
            final String expectedEncoding = tests[i + 1];
            final String targetEncoding = compressor.determineEncoding(acceptEncoding);
            assertEquals(expectedEncoding, targetEncoding);
        }
    }

    @Test
    public void testSplitContent() throws Exception {
        EmbeddedChannel ch = new EmbeddedChannel(new HttpContentCompressor());
        ch.writeInbound(newRequest());

        ch.writeOutbound(new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK));
        ch.writeOutbound(new DefaultHttpContent(Unpooled.copiedBuffer("Hell", CharsetUtil.US_ASCII)));
        ch.writeOutbound(new DefaultHttpContent(Unpooled.copiedBuffer("o, w", CharsetUtil.US_ASCII)));
        ch.writeOutbound(new DefaultLastHttpContent(Unpooled.copiedBuffer("orld", CharsetUtil.US_ASCII)));

        assertEncodedResponse(ch);

        HttpContent chunk;
        chunk = ch.readOutbound();

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free