Question about com.sun.net.httpserver.HttpExchange#sendResponseHeaders

Daniel Fuchs daniel.fuchs at oracle.com
Fri Feb 1 22:58:09 UTC 2019


Hi Wembo,

On 01/02/19 19:50, Wenbo Zhu wrote:
> 1) clarify in the API javadoc that chunked encoding is always applied 
> even with Connection: close

Chunked encoding is always applied if 0 is passed to
sendResponseHeaders (this is a bit counter-intuitive, but
0 means chunked coding and -1 means Content-Length: 0 or
no content - depending on response code, and n > 0 means
Content-Length: n).

Whether chunked coding is applied or not bears no relationship
with Connection: close whatsoever.

On the client side - if we have 200 with no Content-Length
header and no Transfer-Encoding then we don't expect the
content to be chunked. We simply drain the bytes until
EOF is reached.

Is this what you mean by always applied?

best regards,

-- daniel


More information about the net-dev mailing list