RFR: 8331195: Improve com.sun.net.httpserver.HttpExchange usability [v4]

Daniel Fuchs dfuchs at openjdk.org
Wed Nov 5 14:56:18 UTC 2025


On Wed, 5 Nov 2025 13:45:37 GMT, Michael McMahon <michaelm at openjdk.org> wrote:

>> I'd like to return to this issue with a new PR that addresses the usability issue minimally. Namely to define numeric constants
>> for the counter-intuitive responseLength values in `HttpExchange.sendResponseHeaders`. The apidoc then refers to the constant names rather than the numeric values.
>> 
>> I've updated the implementation and some tests (though not all yet) to use the constant names. I'm open to suggestions on the names themselves. Once that is agreed, I'll update the remaining tests and any other call sites in the implementation.
>> 
>> Thanks,
>> Michael
>
> Michael McMahon has updated the pull request incrementally with one additional commit since the last revision:
> 
>   clarify empty byte[] behavior

src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java line 91:

> 89:      * @since 26
> 90:      */
> 91:     public static final long RSPBODY_CHUNKED = 0;

Should we add:

@see #sendResponseHeaders(int, long)


to make it clearer what these constants are for?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28132#discussion_r2494903318


More information about the net-dev mailing list