On Fri, 26 Apr 2024 15:37:13 GMT, robert engels <d...@openjdk.org> wrote:
>> improve the HttpExchange api with documented constants and convenience >> methods to avoid common bugs > > robert engels has updated the pull request incrementally with one additional > commit since the last revision: > > Update > src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java > > Co-authored-by: Michael McMahon > <70538289+michael-mc-ma...@users.noreply.github.com> > > sendResponseHeaderChunked The description implies that this method is > > sending a chunked response, but the method is not doing that. ... > > I don't think it is implying that. The methods: > > ```java > OutputStream sendResponseHeadersChunked(int code); > OutputStream sendResponseHeadersFixed(int code,long length); > ``` > > only inform the server of the response intent. The code must write to and > close the provided OutputStream. > > maybe > > ```java > OutputStream sendResponseHeadersForChunked(int code); > OutputStream sendResponseHeadersForFixed(int code,long length); > ``` > > might be better? Not a huge fan of extras words without a lot of meaning. > > The methods > > ```java > void sendResponseNoContent(int code); > void sendResponse(int code,byte[] data); > ``` > > both close the exchange. No further writes are permitted. The "response" is > fully sent after. your java doc states for the chunked response method * Convenience method to send a chunked response. The caller must write the response * body to the returned output stream and then close it. . . . public final OutputStream sendResponseHeadersChunked(int code) throws IOException { It is not sending a chunked response, nor is it setting the Transfer-Encoding header to chunked for a chunked response For public final void sendResponseHeaders(int code,byte[] data) throws IOException the description is /** * convenience method to send a fixed length response. the output stream is automatically closed and no * further writes are permitted. So it is not just sending response headers it is sending a fixed length response body also the names don't reflect the semantics of the operation described in the methods' javadoc ------------- PR Comment: https://git.openjdk.org/jdk/pull/18955#issuecomment-2088608764