RFR: 8368695: Support 101 switching protocol in jdk.httpserver [v5]

Daniel Fuchs dfuchs at openjdk.org
Wed Feb 11 11:25:10 UTC 2026


On Tue, 10 Feb 2026 16:22:43 GMT, Josiah Noel <duke at openjdk.org> wrote:

>> I must confess I don't know what "legacy" mean because currently the upgrade simply always fails so how could a handler make any use of this?
>
> First, thank you for taking another look at this.
> 
>> Legacy handlers that do not honour the upgrade request will get the wrong kind of input stream here, won't they?
> 
> Not quite, as this stream switch only happens on GET requests matching upgrade semantics. Thus it effectively remains optional as GET request handlers wouldn't attempt to read the body. And even if they persisted for some reason and tried to read the body,  I have kept compatibility by having the stream return nothing if it the connection was not upgraded.

> I must confess I don't know what "legacy" mean because currently the upgrade simply always fails so how could a handler make any use of this?

I know it's been deprecated, but consider the upgrade to HTTP/2 for instance. If the peer doesn't support HTTP/2 it can just ignore the upgrade headers and continue with HTTP/1.1. Upgrade is a rather general mechanism, and for instance, AFAIK, you can even upgrade to HTTP/2 with POST, although it brings its own lot of issues (the request body has to be read using HTTP/1.1 and then only the connection can be upgraded).

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27989#discussion_r2792738746


More information about the net-dev mailing list