On Tue, 14 Sep 2021 16:47:45 GMT, Daniel Fuchs <dfu...@openjdk.org> wrote:
>> This change implements a simple web server that can be run on the >> command-line with `java -m jdk.httpserver`. >> >> This is facilitated by adding an entry point for the `jdk.httpserver` >> module, an implementation class whose main method is run when the above >> command is executed. This is the first such module entry point in the JDK. >> >> The server is a minimal HTTP server that serves the static files of a given >> directory, similar to existing alternatives on other platforms and >> convenient for testing, development, and debugging. >> >> Additionally, a small API is introduced for programmatic creation and >> customization. >> >> Testing: tier1-3. > > 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). ------------- PR: https://git.openjdk.java.net/jdk/pull/5505