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

Josiah Noel duke at openjdk.org
Wed Oct 15 13:13:22 UTC 2025


On Wed, 15 Oct 2025 10:10:00 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

> I would like to see how this new feature would be documented

My thought was to add an implnote to `getRequestBody`  saying something to the effect of:

`@implNote For GET requests with an Upgrade header, the returned stream will not return any data unless the protocol switch is first performed by calling {@link #sendResponseHeaders(int, long) sendResponseHeaders(101, 0)}`

For sendResponseHeaders, it's currently already implied that you can send 101. So I would add an implnote clarifying the behavior. Something like: 

` @implNote This implementation offers limited support for connection upgrade on GET requests.
 If the request included an {@code Upgrade} header, and the response code is 101 (Switching Protocols), then the handler can use the streams returned by {@link #getRequestBody()} and {@link #getResponseBody()} to implement the desired protocol.
`

> more extensive tests will be needed too.

Naturally, tell me what other cases you'd like and it shall be done

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

PR Comment: https://git.openjdk.org/jdk/pull/27751#issuecomment-3406382792


More information about the net-dev mailing list