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

Christoph Läubrich duke at openjdk.org
Wed Dec 24 06:09:06 UTC 2025


On Wed, 17 Dec 2025 04:21:41 GMT, Josiah Noel <duke at openjdk.org> wrote:

>> Remaking the PR since I messed up the upstream merge on the other one. See (https://github.com/openjdk/jdk/pull/27751) for the bulk of the previous discussion
>> 
>> - adds a flag to ExchangeImpl to signal whether the current request is a GET Upgrade request
>> - Adds a new `UpgradeInputStream`/`UpgradeOutputStream` to ensure that the server keeps track of when the upgraded request is closed
>> - on 101 response codes, `sendResponseHeaders` will not immediately close the output stream 
>> - on 101 response codes, `sendResponseHeaders` will use an `UpgradeInputStream`
>
> Josiah Noel has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 18 commits:
> 
>  - Merge branch 'master' into JDK-8368695
>  - Merge branch 'master' into JDK-8368695
>  - reduce diff
>  - Merge remote-tracking branch 'upstream/master' into JDK-8368695
>  - Update SwitchingProtocolTest.java
>  - Update SwitchingProtocolTest.java
>  - Update SwitchingProtocolTest.java
>  - add exception test
>  - Create UpgradeOutputStream.java
>  - close raw streams
>  - ... and 8 more: https://git.openjdk.org/jdk/compare/e635330a...8963e2eb

I really like the idea, simple and effective! Is thee any chance to get this integrated into the next JDK release?

> LGTM — I need this patch for websocket support.

I had the same use-case in mind. I even wonder as the Http Client already supports websocket as a **client** if it would even be feasible to have direct support in the jdk server... it feels like both can share a lot of code and save people from reimplement the raw parts of the protocol.

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

PR Comment: https://git.openjdk.org/jdk/pull/27989#issuecomment-3688784326


More information about the net-dev mailing list