RFR: 8245095: Implementation of JEP 408: Simple Web Server

Michael McMahon michaelm at openjdk.java.net
Wed Sep 15 07:52:49 UTC 2021


On Tue, 14 Sep 2021 16:51:40 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpHandlers.java line 129:
>> 
>>> 127:      * response <i>body bytes</i> are a {@code UTF-8} encoded byte sequence of
>>> 128:      * {@code body}. The response {@linkplain HttpExchange#sendResponseHeaders(int, long) is sent}
>>> 129:      * with the given {@code statusCode} and the body bytes' length. The body
>> 
>> That might give the impression that chunked encoding will be used if the body length is 0. I wonder if it should say instead:
>> 
>> 
>> with the given {@code statusCode} and a {@code Content-Length} field set to the body bytes' length.
>
> Or maybe - which would be more accurate:
> 
> 
> with the given {@code statusCode} and the body bytes' length (or {@code -1} if the body is empty).

I agree with your second suggestion. It's better not to refer to the 'Content-Length' header at all.

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

PR: https://git.openjdk.java.net/jdk/pull/5505


More information about the core-libs-dev mailing list