jdk.httpserver 101 status code closing connection

Daniel Fuchs daniel.fuchs at oracle.com
Wed Sep 3 10:24:29 UTC 2025


Hi Josiah,

This is a feature that is currently not supported by the
jdk.httpserver. Part of a larger problem that support for
sending interim responses (1xx) is currently missing.

The current code has some provision for some one hundred
codes but sendResponseHeaders appears not to have been
designed to send interim responses. This is something we
are aware of - but haven't decided how best to tackle it.
A new method to send interim response codes might be better
than trying to shoehorn sending one hundreds with the
current API, but we haven't investigated that yet.
We have an issue opened that touches on that
(https://bugs.openjdk.org/browse/JDK-8349670)

Making it possible to handle protocols like WebSocket from
within a Handler/Filter would bring that to the next level
though, and I suspect more surgery would be needed.
I am not sure it is something we would be looking forward
to support this in the long run.

best regards,

-- daniel

On 03/09/2025 04:54, Josiah Noel wrote:
> 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.



More information about the net-dev mailing list