Send an HTTP response with trailers using the Java HTTP Server

24 views Asked by At

Using the default implementation of the HTTP server shipped with the JDK (the com.sun.net.httpserver package), how do I send any trailers after I've written out the HTTP response body?

HTTP/1.1 200 OK
Content-Type: text/plain
Transfer-Encoding: chunked
Trailer: Expires

7\r\n
Mozilla\r\n
9\r\n
Developer\r\n
7\r\n
Network\r\n
0\r\n
Expires: Wed, 21 Oct 2015 07:28:00 GMT\r\n
\r\n

It's quite possible to enable the chunked Transfer-Encoding by calling HttpExchange.sendResponseHeaders() with a zero responseLength.

Yet, I'm looking at the source code of sun.net.httpserver.ChunkedOutputStream as well as its usages, but it seems that support for trailers is not implemented.

0

There are 0 answers