On Fri, 3 May 2024 13:53:39 GMT, Ethan McCue <d...@openjdk.org> wrote:

>> I think the solution is to document that the length must be greater than 0 
>> or BBC an IllegalArgumentException is thrown. 
>> 
>> As I mention in the other comment - there is only really a single use for 
>> this - streaming a file of know length. 
>> 
>> This could be removed entirely by a sendResponse(code,Body) or a 
>> sendResponse(code,File)
>> 
>> I think this is being over analyzed though. It’s been here since JDK 11 - 
>> and people have made do. These should be minor changes to improve the 
>> readability and usability- not a wholesale redesign of the api.
>
>> and people have made do
> 
> I think there is cause for this level of analysis. Specifically
> 
> * This API, while part of the JDK, is not in widespread professional use
> * The intended use-case of the API is now "reducing the "getting startup" 
> effort to serve up a web page." [1][2]
> 
> So in that context - that its always going to be a "new" API to those we hope 
> to make use of it - stuff like conceptual gaps (the length is 
> CHUNKED_CONTENT) and footguns (the method that is safer to use is more 
> characters and is named in a way that requires context on how http servers 
> work, not just what they do) at least **feels** important.
> 
> [1]: https://mail.openjdk.org/pipermail/core-libs-dev/2024-January/118266.html
> [2]: https://openjdk.org/jeps/408

I don’t understand. That is why the new methods are added - to remove the 
reliance. 

Instead of beginChunkedResponse() we could use use 
beginVariabkeLengthResponse() and maybe Javadoc that it uses chunked encoding 
to send. 

It would also also a variable response to be buffered and sent as a fixed 
response if it was under a certain length - transparently.

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

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

Reply via email to