Per the HTTP spec, chunked encoding may not be needed if "Connection: close" is set and the TCP connection will be closed (FIN) to complete the response body.
I am yet to write a test for this but the javadoc needs to address this behavior.. This behavior can be supported using the existing API, e.g. by asking the application to add the Connection header before #sendResponseHeaders is called. === I am adding com.sun.net.httpserver. as a lightweight http/1 server runtime for a framework. The (low-level) com.sun.net APIs are very well documented. Thanks for your work on this library. - Wenbo