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

robert engels duke at openjdk.org
Fri Apr 26 15:37:13 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.

It seems like this is a common source of issues though. If the provided length does not match the actual length of the content sent, the connection is completely borked. Clearly this isn't suitable for large responses, and the chunked should be used in that case, so maybe a note around this?

Even if the higher level types became available it would seem trivial to map this to those - similar to how the BodyHandlers work in HttpClient - common ones are provided - this would use those in reverse.

I don't think it is something to hold up the other changes, but I think it warrants a bit more discussion.

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

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


More information about the net-dev mailing list