jdk.httpserver 101 status code closing connection

Josiah Noel josiahnoel at gmail.com
Thu Sep 4 04:05:07 UTC 2025


I've been playing around with it, and it looks like the interim problem of
1xx requests can be resolved if sendResponseHeaders is modified so that the
sentHeaders is not set to true for 1xx status codes.

The fix would be:

   - Check for 1xx status code
   - If so, do not close the streams
   - flush (but don't close) the raw outputstream
   - set sentHeaders to false

With this, I was able to call sendResponseHeaders again with the full
response code and have it work. Thoughts?

- will the server keep a reference to the connection/socket
>

Digging deeper into the code, the server already keeps a reference of every
active connection, which is why the stop methods worked as normal. The
Dispatcher thread also handles terminating the connection when the stream
is closed manually.

Can you think of any other potential issues/scenarios with keeping the
streams available for 1xx codes?

Thanks for your time,

-- Josiah
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/net-dev/attachments/20250904/24afe35b/attachment.htm>


More information about the net-dev mailing list