private void send(InputStream input) throws IOException { try { // by calling httpServletResponse.getOutputStream() we are committing the response IoUtils.copy(input, httpServletResponse.getOutputStream()); if (chunked) { // flushing the buffer forces chunked-encoding httpServletResponse.flushBuffer(); } } finally { IoUtils.close(input); } }