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 — HttpServerUpgradeHandler should be removed when there is no upgrade · Issue #15489 · netty/netty

HttpServerUpgradeHandler should be removed when there is no upgrade #15489

New issue
Copy link
New issue
Copy link
Closed
#15594
Closed
HttpServerUpgradeHandler should be removed when there is no upgrade#15489
#15594
Copy link
Milestone
4.2.5.Final

Description

@brucelwl
brucelwl
opened on Jul 14, 2025
Issue body actions

https://github.com/netty/netty/blob/a7c4a3bcbde567a08c84f3e60b4ad3a11f564a42/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerUpgradeHandler.java#L259-L263

HttpServerUpgradeHandler should be removed by Invoke ctx.pipeline().remove(this); when there is no upgrade
Otherwise, it will lead to unnecessary repeated upgrade checks

Below is the sample code

else { 
     ReferenceCountUtil.retain(msg); 

     ctx.pipeline().remove(this);

     ctx.fireChannelRead(msg); 
     return; 
 } 

Activity

  1. yawkat commented on Jul 15, 2025

    @yawkat
    yawkat
    on Jul 15, 2025
    Contributor
    More actions

    Correct me if I'm wrong, but I don't think there is a general requirement that the upgrade be the first message.

  2. brucelwl commented on Jul 15, 2025

    @brucelwl
    brucelwl
    on Jul 15, 2025
    ContributorAuthor
    More actions

    @yawkat Thank you for your reply

    I'm not sure if only the first request is considered an upgrade request according to the HTTP protocol, but I found that the CleartextHttp2ServerUpgradeHandler removes itself if there is no upgrade

    According to experience, if there is an upgrade request, a upgrade message is usually sent in the first request.

    netty/codec-http2/src/main/java/io/netty/handler/codec/http2/CleartextHttp2ServerUpgradeHandler.java

    Lines 79 to 82 in c60c845

    if (!ByteBufUtil.equals(CONNECTION_PREFACE, CONNECTION_PREFACE.readerIndex(),
    in, in.readerIndex(), bytesRead)) {
    ctx.pipeline().remove(this);
    } else if (bytesRead == prefaceLength) {

  3. normanmaurer commented on Aug 29, 2025

    @normanmaurer
    normanmaurer
    on Aug 29, 2025
    Member
    More actions

    @brucelwl generally speaking for HTTP 1.1 it's not a requirement that the first request must be the upgrade request. Some protocols make this more strict later on, like for example WebSockets which says it must be the first. So I think we are better of not making this change by default. That said we can introduce a new constructor that will allow to specify if we expect it to be the first or not. Let me do a PR.

    Reacted by bruce
  4. normanmaurer
    added a commit that references this issue on Aug 29, 2025

    HTTP: Allow to configure HttpServerUpgradeHandler to remove itself af…

    58d6bb7
  5. normanmaurer commented on Aug 29, 2025

    @normanmaurer
    normanmaurer
    on Aug 29, 2025
    Member
    More actions

    @yawkat @brucelwl PTAL #15594

    Reacted by bruce
  6. normanmaurer
    added this to the 4.2.5.Final milestone on Aug 29, 2025
  7. normanmaurer
    closed this as completedin #15594on Aug 30, 2025
  8. normanmaurer
    added a commit that references this issue on Sep 1, 2025

    HTTP: Allow to configure HttpServerUpgradeHandler to remove itself af… (

    6c3e1c1
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

      • 4.2.5.Final

      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.