Home / Class/ HttpUtilTest Class — netty Architecture

HttpUtilTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e["HttpUtilTest"]
  309c5ff9_915e_12e4_3214_a143aaf1d9e7["HttpUtilTest.java"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|defined in| 309c5ff9_915e_12e4_3214_a143aaf1d9e7
  7358d137_6aac_0f28_4280_377d42411421["testRecognizesOriginForm()"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|method| 7358d137_6aac_0f28_4280_377d42411421
  651a8a45_3c05_2010_dba2_eaafe1149659["testRecognizesAsteriskForm()"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|method| 651a8a45_3c05_2010_dba2_eaafe1149659
  62a622a1_50fe_0fbd_4a15_3c8c50c2ba71["requestLineTokenValidationMustRejectInvalidTokens()"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|method| 62a622a1_50fe_0fbd_4a15_3c8c50c2ba71
  54dd9009_208d_daed_1697_8f5a46393584["testRemoveTransferEncodingIgnoreCase()"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|method| 54dd9009_208d_daed_1697_8f5a46393584
  8b2209a3_4eb4_5983_d76d_32e98ee253be["testGetOperations()"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|method| 8b2209a3_4eb4_5983_d76d_32e98ee253be
  42e3a0d1_476d_1427_714f_7763b858687b["testGetCharsetAsRawCharSequence()"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|method| 42e3a0d1_476d_1427_714f_7763b858687b
  a88c799d_1066_1126_1185_1086fe313d90["testGetCharset()"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|method| a88c799d_1066_1126_1185_1086fe313d90
  dddffeeb_69ef_709e_b1e2_dd5a67565be4["testGetCharsetNoSpace()"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|method| dddffeeb_69ef_709e_b1e2_dd5a67565be4
  83bf01d7_df98_d415_9fed_f1447e74073a["testGetCharsetQuoted()"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|method| 83bf01d7_df98_d415_9fed_f1447e74073a
  a5aa94d3_52ca_173c_51b8_2d3c4022f1f2["testGetCharsetNoSpaceQuoted()"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|method| a5aa94d3_52ca_173c_51b8_2d3c4022f1f2
  1817e9f4_e66c_1611_f584_845c591af40d["testGetCharsetUtf8()"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|method| 1817e9f4_e66c_1611_f584_845c591af40d
  bb1ac6ae_1961_06ae_4625_94d8e729c587["testGetCharsetNoLeadingQuotes()"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|method| bb1ac6ae_1961_06ae_4625_94d8e729c587
  73a35a81_2fd0_1915_b48d_fcee1c426770["testGetCharsetNoTrailingQuotes()"]
  04f193b8_77e1_8af0_51b3_8dcd3ac8de0e -->|method| 73a35a81_2fd0_1915_b48d_fcee1c426770

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/HttpUtilTest.java lines 45–538

public class HttpUtilTest {

    @Test
    public void testRecognizesOriginForm() {
        // Origin form: https://tools.ietf.org/html/rfc7230#section-5.3.1
        assertTrue(HttpUtil.isOriginForm(URI.create("/where?q=now")));
        // Absolute form: https://tools.ietf.org/html/rfc7230#section-5.3.2
        assertFalse(HttpUtil.isOriginForm(URI.create("http://www.example.org/pub/WWW/TheProject.html")));
        // Authority form: https://tools.ietf.org/html/rfc7230#section-5.3.3
        assertFalse(HttpUtil.isOriginForm(URI.create("www.example.com:80")));
        // Asterisk form: https://tools.ietf.org/html/rfc7230#section-5.3.4
        assertFalse(HttpUtil.isOriginForm(URI.create("*")));
    }

    @Test
    public void testRecognizesAsteriskForm() {
        // Asterisk form: https://tools.ietf.org/html/rfc7230#section-5.3.4
        assertTrue(HttpUtil.isAsteriskForm(URI.create("*")));
        // Origin form: https://tools.ietf.org/html/rfc7230#section-5.3.1
        assertFalse(HttpUtil.isAsteriskForm(URI.create("/where?q=now")));
        // Absolute form: https://tools.ietf.org/html/rfc7230#section-5.3.2
        assertFalse(HttpUtil.isAsteriskForm(URI.create("http://www.example.org/pub/WWW/TheProject.html")));
        // Authority form: https://tools.ietf.org/html/rfc7230#section-5.3.3
        assertFalse(HttpUtil.isAsteriskForm(URI.create("www.example.com:80")));
    }

    @ParameterizedTest
    @ValueSource(strings = {
            "http://localhost/\r\n",
            "/r\r\n?q=1",
            "http://localhost/\r\n?q=1",
            "/r\r\n/?q=1",
            "http://localhost/\r\n/?q=1",
            "/r\r\n",
            "http://localhost/ HTTP/1.1\r\n\r\nPOST /p HTTP/1.1\r\n\r\n",
            "/r HTTP/1.1\r\n\r\nPOST /p HTTP/1.1\r\n\r\n",
            "GET ",
            " GET",
            "HTTP/ 1.1",
            "HTTP/\r0.9",
            "HTTP/\n1.1",
    })
    public void requestLineTokenValidationMustRejectInvalidTokens(String token) throws Exception {
        assertFalse(HttpUtil.isEncodingSafeStartLineToken(token));
    }

    @Test
    public void testRemoveTransferEncodingIgnoreCase() {
        HttpMessage message = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
        message.headers().set(HttpHeaderNames.TRANSFER_ENCODING, "Chunked");
        assertFalse(message.headers().isEmpty());
        HttpUtil.setTransferEncodingChunked(message, false);
        assertTrue(message.headers().isEmpty());
    }

    // Test for https://github.com/netty/netty/issues/1690
    @Test
    public void testGetOperations() {
        HttpHeaders headers = new DefaultHttpHeaders();
        headers.add(of("Foo"), of("1"));
        headers.add(of("Foo"), of("2"));

        assertEquals("1", headers.get(of("Foo")));

        List<String> values = headers.getAll(of("Foo"));
        assertEquals(2, values.size());
        assertEquals("1", values.get(0));
        assertEquals("2", values.get(1));
    }

    @Test
    public void testGetCharsetAsRawCharSequence() {
        String QUOTES_CHARSET_CONTENT_TYPE = "text/html; charset=\"utf8\"";
        String SIMPLE_CONTENT_TYPE = "text/html";

        HttpMessage message = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
        message.headers().set(HttpHeaderNames.CONTENT_TYPE, QUOTES_CHARSET_CONTENT_TYPE);
        assertEquals("\"utf8\"", HttpUtil.getCharsetAsSequence(message));
        assertEquals("\"utf8\"", HttpUtil.getCharsetAsSequence(QUOTES_CHARSET_CONTENT_TYPE));

        message.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/html");

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free