jdk.httpserver 101 status code closing connection

Josiah Noel josiahnoel at gmail.com
Wed Sep 3 03:54:01 UTC 2025


Hey team,

I was trying to manually implement a WebSocket using the jdk.httpserver
module, but it seems that when I use sendHeaders to send a 101 status code,
the request is terminated and the streams are closed, preventing me from
reading/sending websocket frames.

Is it right to say that we shouldn't close the exchange in this situation?
Just to clarify, this is *not* a request for adding an implementation of
the websocket protocol to the module.

The fix would would be:

   - Check request connection header to see if it is an upgrade request
   - If so, set getRequestBody/getResponseBody to return the raw streams
   - flush (but don't close) the outputstream when sending a 101 status code

I am willing to contribute this myself. (Indeed I already have the changes
on my local)

-- 
Cheers, Josiah.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/net-dev/attachments/20250902/6d96a839/attachment.htm>


More information about the net-dev mailing list