HttpExchange.sendResponseHeaders takes two parameters - the int responseCode and a long parameter which specifies the content length.
The content-length parameter is counter intuitive where the value 0 means use chunked encoding, whereas the value -1 (or any value < 0) means no content.
A simple improvement could be to add two symbolic constant values to HttpExchange such as:
public static final long NO_CONTENT = -1L;
and
public static final long CHUNKED_CONTENT = 0L;
A convenience method for sending no content could be added such as:
public final void sendResponseHeadersNoContent(int code)
An apiNote can be added to the existing sendResponseHeaders method referring to the constants and the new method
The content-length parameter is counter intuitive where the value 0 means use chunked encoding, whereas the value -1 (or any value < 0) means no content.
A simple improvement could be to add two symbolic constant values to HttpExchange such as:
public static final long NO_CONTENT = -1L;
and
public static final long CHUNKED_CONTENT = 0L;
A convenience method for sending no content could be added such as:
public final void sendResponseHeadersNoContent(int code)
An apiNote can be added to the existing sendResponseHeaders method referring to the constants and the new method
- links to
-
Review(master) openjdk/jdk/18955