On Tue, 4 Nov 2025 16:02:41 GMT, Daniel Fuchs <[email protected]> wrote:

> This is a good idea, but it kind of hides the fact that passing 0 may not do 
> what you think it does.
> 
> Typically the pitfall is to assume that if you have an array of bytes then 
> you can can call `sendResponseHeaders` with the array length. The API doc of 
> `sendResponseHeaders` should probably make it clear that 0 is a special 
> value, and that `RSPBODY_CHUNKED` is 0.
> 
> In addition I would suggest adding code snipets showing both cases (one using 
> a byte array and passing `bytes.length == 0 ? RSPBODY_EMPTY : bytes.length` 
> and the other using `RSPBODY_CHUNKED` with e.g. transferring the content of 
> an `InputStream`.

I've added an API note. I'd prefer not to drown the whole spec out with code 
samples just for this issue if possible.

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

PR Comment: https://git.openjdk.org/jdk/pull/28132#issuecomment-3489892074

Reply via email to