RFR: 8368695: Support 101 switching protocol in jdk.httpserver [v3]
Daniel Fuchs
dfuchs at openjdk.org
Tue Oct 14 16:28:43 UTC 2025
On Fri, 10 Oct 2025 21:22:49 GMT, Josiah Noel <duke at openjdk.org> wrote:
>> - adds a flag to ExchangeImpl to signal whether the current request is an Upgrade request
>> - Adds a new `UpgradeInputStream` 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 `UndefLengthOutputStream`
>
> Josiah Noel has updated the pull request incrementally with one additional commit since the last revision:
>
> Update UpgradeInputStream.java
But that would be an incompatible change, isn't it?
Consider the following:
httpserver.createContext("/echo/", (exch) -> {
byte[] bytes;
try (var is = exch.getRequestBody()) { bytes = is.readAllBytes(); }
exch.sendResponseHeaders(200, bytes.length == 0 ? -1 : bytes.length);
try (var os = exch.getResponseBody()) { if (bytes.length > 0) os.write(bytes); }
});
wouldn't that now block forever if the request contains an upgrade header?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27751#issuecomment-3402699078
More information about the net-dev
mailing list