GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — HttpServerCodec always constructs an "EmptyLastHttpContent" and passes it to the Handler chain when processing OPTIONS requests · Issue #15148 · netty/netty

HttpServerCodec always constructs an "EmptyLastHttpContent" and passes it to the Handler chain when processing OPTIONS requests #15148

New issue
Copy link
New issue
Copy link
Closed
#15941
Closed
HttpServerCodec always constructs an "EmptyLastHttpContent" and passes it to the Handler chain when processing OPTIONS requests#15148
#15941
Copy link

Description

@anren1024
anren1024
opened on May 11, 2025
Issue body actions

HttpServerCodec always constructs an "EmptyLastHttpContent" and passes it to the Handler chain when processing OPTIONS requests, The "EmptyLastHttpContent" propagate through the handler chain.

If a CORS handler is added to the pipeline, it may prematurely return a response to the HTTP client.

However, the CORS handler might still propagate the EmptyLastHttpContent to downstream handlers via fireChannelRead(), causing subsequent handlers to receive only this empty content and lose access to the original request URL.

Can the CORSHandler be configured to directly consume/discard the EmptyLastHttpContent?

simple channel:

 ServerBootstrap b = new ServerBootstrap();
                b.group(bossGroup, workerGroup)
                    .channel(NioServerSocketChannel.class)
                    .childHandler(new ChannelInitializer<SocketChannel>() {
                        @Override
                        protected void initChannel(SocketChannel ch) {
                            
                            ch.pipeline().addLast(new HttpServerCodec())

                                .addLast(new CorsHandler(CorsConfigBuilder.forAnyOrigin()
                                    .allowedRequestMethods(HttpMethod.GET, HttpMethod.POST, HttpMethod.PUT, HttpMethod.DELETE, HttpMethod.OPTIONS)
                                    .allowedRequestHeaders("*")
                                    .maxAge(3600L)
                                    .allowNullOrigin()
                                    .build()))

                                .addLast(new SimpleHandler())

SimpleHandler:

public SimpleHandler extends ChannelInboundHandlerAdapter {
    private static final Logger log = LoggerFactory.getLogger(SimpleHandler.class);

    private boolean isOption;
 
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) {
         if (msg instanceof HttpRequest req) {
              isOption = req.method() == HttpMethod.OPTIONS;
         }
                                        
          if (msg instanceof LastHttpContent && isOption && msg.toString().equals("EmptyLastHttpContent")) {
                log.info("an EmptyLastHttpContent");
                return;
          }
         ctx.fireChannelRead(msg);
  }
}

Activity

  1. normanmaurer
    added a commit that references this issue on Dec 3, 2025

    Discard the following HttpContent for preflight request (#15941)

    This issue will close once commit 28e8017 is merged into the '4.2' branch.
    28e8017
  2. normanmaurer
    closed this as completedin #15941on Dec 3, 2025
  3. normanmaurer
    added 2 commits that reference this issue on Dec 3, 2025

    Discard the following HttpContent for preflight request (#15941)

    This issue will close once commit e502b39 is merged into the '4.2' branch.
    e502b39

    Discard the following HttpContent for preflight request (#15941)

    This issue will close once commit cf8280b is merged into the '4.2' branch.
    cf8280b
  4. chrisvest
    added a commit that references this issue on Dec 3, 2025

    Discard the following HttpContent for preflight request (#15941) (#15962

    This issue will close once commit 11346d6 is merged into the '4.2' branch.
    11346d6
  5. normanmaurer
    added a commit that references this issue on Dec 4, 2025

    Discard the following HttpContent for preflight request (#15941) (#15963

    This issue will close once commit 8296b7c is merged into the '4.2' branch.
    8296b7c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.