Home / Function/ testInitialMessage() — netty Function Reference

testInitialMessage() — netty Function Reference

Architecture documentation for the testInitialMessage() function in HttpProxyHandlerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  28ef3cf9_cc4c_2f0a_2918_784cd7fbebca["testInitialMessage()"]
  4863804c_b04f_6a7f_744b_534e664fa2c9["HttpProxyHandlerTest"]
  28ef3cf9_cc4c_2f0a_2918_784cd7fbebca -->|defined in| 4863804c_b04f_6a7f_744b_534e664fa2c9
  ba58e338_0e9a_0780_1786_86adf54e4fff["testHostname()"]
  ba58e338_0e9a_0780_1786_86adf54e4fff -->|calls| 28ef3cf9_cc4c_2f0a_2918_784cd7fbebca
  a0ccc851_b7ec_625e_7aa0_0bff2d939b66["testHostnameUnresolved()"]
  a0ccc851_b7ec_625e_7aa0_0bff2d939b66 -->|calls| 28ef3cf9_cc4c_2f0a_2918_784cd7fbebca
  af58a712_fdeb_01f3_7ae1_d528ac6e713f["testHostHeaderWithHttpDefaultPort()"]
  af58a712_fdeb_01f3_7ae1_d528ac6e713f -->|calls| 28ef3cf9_cc4c_2f0a_2918_784cd7fbebca
  d31f0b9a_457f_02a6_b6cd_bdb9e3b70e70["testHostHeaderWithHttpDefaultPortIgnored()"]
  d31f0b9a_457f_02a6_b6cd_bdb9e3b70e70 -->|calls| 28ef3cf9_cc4c_2f0a_2918_784cd7fbebca
  ad0a5016_2a3d_8c84_b16d_33c1bae57ad8["testHostHeaderWithHttpsDefaultPort()"]
  ad0a5016_2a3d_8c84_b16d_33c1bae57ad8 -->|calls| 28ef3cf9_cc4c_2f0a_2918_784cd7fbebca
  bd3d65f2_53e2_15e2_8f93_ca7479312a13["testHostHeaderWithHttpsDefaultPortIgnored()"]
  bd3d65f2_53e2_15e2_8f93_ca7479312a13 -->|calls| 28ef3cf9_cc4c_2f0a_2918_784cd7fbebca
  b9b92aad_5ab4_7750_948a_72f6f6a3f41f["testIpv6()"]
  b9b92aad_5ab4_7750_948a_72f6f6a3f41f -->|calls| 28ef3cf9_cc4c_2f0a_2918_784cd7fbebca
  44c0dc9d_cd09_04ed_fc70_3a8e00223193["testIpv6Unresolved()"]
  44c0dc9d_cd09_04ed_fc70_3a8e00223193 -->|calls| 28ef3cf9_cc4c_2f0a_2918_784cd7fbebca
  2d59513d_204e_5a93_1d01_4c3aa74fc7a5["testIpv4()"]
  2d59513d_204e_5a93_1d01_4c3aa74fc7a5 -->|calls| 28ef3cf9_cc4c_2f0a_2918_784cd7fbebca
  fb11fc4a_b39f_d6bb_02da_181fca1c790d["testIpv4Unresolved()"]
  fb11fc4a_b39f_d6bb_02da_181fca1c790d -->|calls| 28ef3cf9_cc4c_2f0a_2918_784cd7fbebca
  85234e40_5708_19e4_5538_103e27ff78ec["testCustomHeaders()"]
  85234e40_5708_19e4_5538_103e27ff78ec -->|calls| 28ef3cf9_cc4c_2f0a_2918_784cd7fbebca
  style 28ef3cf9_cc4c_2f0a_2918_784cd7fbebca fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler-proxy/src/test/java/io/netty/handler/proxy/HttpProxyHandlerTest.java lines 238–274

    private static void testInitialMessage(InetSocketAddress socketAddress,
                                           String expectedUrl,
                                           String expectedHostHeader,
                                           HttpHeaders headers,
                                           boolean ignoreDefaultPortsInConnectHostHeader) throws Exception {
        InetSocketAddress proxyAddress = new InetSocketAddress(NetUtil.LOCALHOST, 8080);

        ChannelPromise promise = mock(ChannelPromise.class);
        verifyNoMoreInteractions(promise);

        ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);
        when(ctx.connect(same(proxyAddress), isNull(InetSocketAddress.class), same(promise))).thenReturn(promise);

        HttpProxyHandler handler = new HttpProxyHandler(
                new InetSocketAddress(NetUtil.LOCALHOST, 8080),
                headers,
                ignoreDefaultPortsInConnectHostHeader);
        handler.connect(ctx, socketAddress, null, promise);

        FullHttpRequest request = (FullHttpRequest) handler.newInitialMessage(ctx);
        try {
            assertEquals(HttpVersion.HTTP_1_1, request.protocolVersion());
            assertEquals(expectedUrl, request.uri());
            HttpHeaders actualHeaders = request.headers();
            assertEquals(expectedHostHeader, actualHeaders.get(HttpHeaderNames.HOST));

            if (headers != null) {
                // The actual request header is a strict superset of the custom header
                for (String name : headers.names()) {
                    assertEquals(headers.getAll(name), actualHeaders.getAll(name));
                }
            }
        } finally {
            request.release();
        }
        verify(ctx).connect(proxyAddress, null, promise);
    }

Domain

Subdomains

Frequently Asked Questions

What does testInitialMessage() do?
testInitialMessage() is a function in the netty codebase, defined in handler-proxy/src/test/java/io/netty/handler/proxy/HttpProxyHandlerTest.java.
Where is testInitialMessage() defined?
testInitialMessage() is defined in handler-proxy/src/test/java/io/netty/handler/proxy/HttpProxyHandlerTest.java at line 238.
What calls testInitialMessage()?
testInitialMessage() is called by 11 function(s): testCustomHeaders, testHostHeaderWithHttpDefaultPort, testHostHeaderWithHttpDefaultPortIgnored, testHostHeaderWithHttpsDefaultPort, testHostHeaderWithHttpsDefaultPortIgnored, testHostname, testHostnameUnresolved, testIpv4, and 3 more.

Analyze Your Own Codebase

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

Try Supermodel Free