RFR: 8331195: Improve com.sun.net.httpserver.HttpExchange usability [v4]
    Ethan McCue 
    duke at openjdk.org
       
    Fri May  3 13:27:55 UTC 2024
    
    
  
On Wed, 1 May 2024 21:12:05 GMT, robert engels <duke at 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 two additional commits since the last revision:
> 
>  - Merge remote-tracking branch 'robaho/HttpExchange-api-change' into HttpExchange-api-change
>    
>    # Conflicts:
>    #	src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java
>  - update api changes based on comments
src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java line 252:
> 250:         sendResponseHeaders(code,length);
> 251:         return getResponseBody();
> 252:     }
I'm not convinced that having this method will be enough to prevent common errors.
* It is more verbose than `sendResponseHeaders`
* As you've pointed out you need to have knowledge of the http protocol in order to grok what is going on. "Sending headers" might still be reached for first by gen-pop
* The `length` parameter here would be subtly different than the `responseLength` in `sendResponseHeaders`. (the 0, -1 thing). This feels like it makes the situation worse (not only is it weird to have -1 be no content and 0 be chunked - now its inconsistent)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18955#discussion_r1589200900
    
    
More information about the net-dev
mailing list