RFR: 8368695: Support 101 switching protocol in jdk.httpserver [v3]

Josiah Noel duke at openjdk.org
Tue Oct 14 13:51:48 UTC 2025


On Tue, 14 Oct 2025 13:33:45 GMT, Josiah Noel <duke at openjdk.org> wrote:

> work the same as an extended GET request.

In fact, this might be a good way of thinking about it. When you call `sendResponseHeaders(200, 0)` a similar thing happens to what I'm asking for 101. The streams are not closed, and the handler is free to read the inputstream and write to the outputstream as it pleases.


    server.createContext(
        "/test",
        exchange -> {
          exchange.sendResponseHeaders(200, 0);
          exchange.getResponseBody().write("My Response".getBytes());
          try (var is = exchange.getRequestBody()) {
            is.transferTo(exchange.getResponseBody());
          }
        });

-------------

PR Comment: https://git.openjdk.org/jdk/pull/27751#issuecomment-3401986420


More information about the net-dev mailing list