Home / Function/ preflightEmptyLastDiscardedThenNewRequestForwarded() — netty Function Reference

preflightEmptyLastDiscardedThenNewRequestForwarded() — netty Function Reference

Architecture documentation for the preflightEmptyLastDiscardedThenNewRequestForwarded() function in CorsHandlerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  6c8aa562_46d4_3fd0_68ae_ccd2ecc529bb["preflightEmptyLastDiscardedThenNewRequestForwarded()"]
  e946b2e4_b243_053e_5c0a_3d1a9a50042d["CorsHandlerTest"]
  6c8aa562_46d4_3fd0_68ae_ccd2ecc529bb -->|defined in| e946b2e4_b243_053e_5c0a_3d1a9a50042d
  style 6c8aa562_46d4_3fd0_68ae_ccd2ecc529bb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java lines 633–666

    @Test
    public void preflightEmptyLastDiscardedThenNewRequestForwarded() {
        CorsConfig config = forOrigin("http://allowed").build();
        EmbeddedChannel ch = new EmbeddedChannel(new CorsHandler(config));

        // Preflight request
        FullHttpRequest preflight = new DefaultFullHttpRequest(HTTP_1_1, OPTIONS, "/pre");
        preflight.headers().set(ORIGIN, "http://allowed");
        preflight.headers().set(ACCESS_CONTROL_REQUEST_METHOD, "GET");
        assertFalse(ch.writeInbound(preflight));
        Object preflightResp = ch.readOutbound();
        assertNotNull(preflightResp);
        ReferenceCountUtil.release(preflightResp);

        // Empty last content should be discarded
        assertFalse(ch.writeInbound(LastHttpContent.EMPTY_LAST_CONTENT));
        assertNull(ch.readInbound());

        // New request should be forwarded
        FullHttpRequest req = new DefaultFullHttpRequest(HTTP_1_1, GET, "/next");
        req.headers().set(ORIGIN, "http://allowed");
        assertTrue(ch.writeInbound(req));

        Object firstInbound = ch.readInbound();
        assertNotNull(firstInbound);

        HttpContent content = new DefaultHttpContent(Unpooled.copiedBuffer("test message", CharsetUtil.UTF_8));
        assertTrue(ch.writeInbound(content));
        Object secondInbound = ch.readInbound();
        assertNotNull(secondInbound);

        assertNull(ch.readInbound());
        assertFalse(ch.finish());
    }

Domain

Subdomains

Frequently Asked Questions

What does preflightEmptyLastDiscardedThenNewRequestForwarded() do?
preflightEmptyLastDiscardedThenNewRequestForwarded() is a function in the netty codebase, defined in codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java.
Where is preflightEmptyLastDiscardedThenNewRequestForwarded() defined?
preflightEmptyLastDiscardedThenNewRequestForwarded() is defined in codec-http/src/test/java/io/netty/handler/codec/http/cors/CorsHandlerTest.java at line 633.

Analyze Your Own Codebase

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

Try Supermodel Free