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

Daniel Fuchs dfuchs at openjdk.org
Tue Apr 30 15:38:07 UTC 2024


On Fri, 26 Apr 2024 14:54:30 GMT, Michael McMahon <michaelm at openjdk.org> wrote:

>> 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-Mahon at users.noreply.github.com>
>
> src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java line 246:
> 
>> 244:      * @see HttpExchange#sendResponseHeaders(int, long)
>> 245:      */
>> 246:     public final void sendResponseHeaders(int code,byte[] data) throws IOException {
> 
> I'd prefer to drop this method. Some time in the future we might come up with a better mechanism for handling request and response bodies and translating them to higher level types.

If we keep this method then I think it should be named `sendResponse` since it sends the response (and not only the headers). It seems a bit limiting that it requires a single byte array - but on the other hand that's what we use in probably 80% of the tests. On the other hand it seems to promote a single `byte[]` array as first class citizen - and as @Michael-Mc-Mahon  says, that might not be the best choice. Agreed that we can discuss it though.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18955#discussion_r1585055894


More information about the net-dev mailing list