RFR: 8368695: Support 101 switching protocol in jdk.httpserver [v5]
Josiah Noel
duke at openjdk.org
Wed Feb 11 09:39:52 UTC 2026
On Tue, 10 Feb 2026 16:20:45 GMT, Christoph Läubrich <duke at openjdk.org> wrote:
>> src/jdk.httpserver/share/classes/sun/net/httpserver/ExchangeImpl.java line 183:
>>
>>> 181: uis_orig = new UpgradeInputStream(this, ris);
>>> 182: } else if (reqContentLen == -1L) {
>>> 183: uis_orig = new ChunkedInputStream(this, ris);
>>
>> I would much prefer the code in the HttpHandler to opt-in for the upgrade, rather than considering that it will honour it by default. Legacy handlers that do not honour the upgrade request will get the wrong kind of input stream here, won't they?
>
> I must confess I don't know what "legacy" mean because currently the upgrade simply always fails so how could a handler make any use of this?
First, thank you for taking another look at this.
> Legacy handlers that do not honour the upgrade request will get the wrong kind of input stream here, won't they?
Not quite, as this stream switch only happens on GET requests matching upgrade semantics. Thus it effectively remains optional as GET request handlers wouldn't attempt to read the body. And even if they persisted for some reason and tried to read the body, I have kept compatibility by having the stream return nothing if it the connection was not upgraded.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27989#discussion_r2788965474
More information about the net-dev
mailing list