On 03/06/2016 15:14, Mark Thomas wrote: > On 01/06/2016 23:08, Steffen Heil (Mailinglisten) wrote: >>>> That's another story. >>>> I tried that. And the internet explorer as well as curl report an error, >>>> if the download stops without the ending 0\r\n. >>>> >>>> But I had to set "Connection: close" and "Transfer-Encoding: chunked" >>>> myself and encode the chunk headers myself. >>>> If I leave these two headers out, tomcat managed the transfer-encoding (as >>>> I set no Content-Length header) which I would prefer. >>>> However then I find no way to close the connection. If I call "close()" on >>>> the OutputStream tomcat sends 0\r\n. >>>> Even if I throw an exception, tomcat "correctly" closes the stream. >>>> I did not find any way to close it without that. >>>> >>>> Is there any way to do so? >>> >>> Tomcat version? >> >> 8.0.26 > > There was a change back in 8.0.9 that I thought addressed this. I need > to do a little digging.
OK. I've confirmed that the fix back in 8.0.9 did what I thought it did with a simple test. The GET method of my test Servlet looks like this: protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/plain"); resp.setCharacterEncoding("UTF-8"); resp.getWriter().write("OK\n"); resp.flushBuffer(); resp.getWriter().write("OK\n"); resp.flushBuffer(); throw new ServletException(); } The client receives a chunked response that looks like this: HTTP/1.1 200 Content-Type: text/plain;charset=UTF-8 Transfer-Encoding: chunked Date: Fri, 03 Jun 2016 14:30:33 GMT 3 OK <Connection closed here> The client should be able to work out the response is incomplete because there is no end chunk ("0\r\n\r\n"). There isn't much else Tomcat can do. It can't change the headers because the response is committed. Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org