RFR: 8368695: Support 101 switching protocol in jdk.httpserver [v10]
Daniel Fuchs
dfuchs at openjdk.org
Wed Feb 18 15:03:40 UTC 2026
On Wed, 18 Feb 2026 14:43:24 GMT, Josiah Noel <duke at openjdk.org> wrote:
>> src/jdk.httpserver/share/classes/sun/net/httpserver/UpgradeInputStream.java line 46:
>>
>>> 44: if (!t.upgraded) {
>>> 45: return -1;
>>> 46: }
>>
>> This will prevent draining the input stream properly if the request is not upgraded.
>
> the recent commit prevents an UpgradeInputStream from being given if the GET request has a body, so there is nothing to drain.
OK - yes - I can accept that.
>> src/jdk.httpserver/share/classes/sun/net/httpserver/UpgradeInputStream.java line 69:
>>
>>> 67: t.getServerImpl().requestCompleted(t.getConnection());
>>> 68: }
>>> 69: }
>>
>> This is incorrect if `t.upgraded == false`. I believe there need to be more thought about what happens when an upgrade request is not upgraded.
>
>> This is incorrect if t.upgraded == false
>
> Perchance could you briefly explain why? I'm afraid I don't follow
If the connection is not upgraded then it should behave as a regular request, and drain whatever there is to drain if the client has sent bytes. However I realize this is more a feature for the other subclasses of LeftOverInputStream - which have a means to know how much should be drained. And here we made sure that there was no Content-Length/Transfer-Encoding - so the only possible edge case that may need to be taken care of is the HTTP version. Maybe we need to check that the version is HTTP/1.1 too before marking the exchange as a potential upgrade (that is - exclude HTTP/1.0).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27989#discussion_r2822774279
PR Review Comment: https://git.openjdk.org/jdk/pull/27989#discussion_r2822762634
More information about the net-dev
mailing list