Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try sending them in chunks along with <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.41" rel="noreferrer"><code>Transfer-Encoding:</code></a> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1" rel="noreferrer"><code>chunked</code></a>. More details in <a href="http://en.wikipedia.org/wiki/Chunked_transfer_encoding" rel="noreferrer">wikipedia</a>.</p> <p><strong>Update</strong> as per the comments, here's an example how a "ChunkedOutputStream" in Java may look like:</p> <pre><code>package com.stackoverflow.q2395192; import java.io.IOException; import java.io.OutputStream; public class ChunkedOutputStream extends OutputStream { private static final byte[] CRLF = "\r\n".getBytes(); private OutputStream output = null; public ChunkedOutputStream(OutputStream output) { this.output = output; } @Override public void write(int i) throws IOException { write(new byte[] { (byte) i }, 0, 1); } @Override public void write(byte[] b, int offset, int length) throws IOException { writeHeader(length); output.write(CRLF, 0, CRLF.length); output.write(b, offset, length); output.write(CRLF, 0, CRLF.length); } @Override public void flush() throws IOException { output.flush(); } @Override public void close() throws IOException { writeHeader(0); output.write(CRLF, 0, CRLF.length); output.write(CRLF, 0, CRLF.length); output.close(); } private void writeHeader(int length) throws IOException { byte[] header = Integer.toHexString(length).getBytes(); output.write(header, 0, header.length); } } </code></pre> <p>...which can basically be used as:</p> <pre><code>OutputStream output = new ChunkedOutputStream(response.getOutputStream()); output.write(....); </code></pre> <p>You see in the source, every chunk of data exist of a header which represents the length of data in hex, a CRLF, the actual data and a CRLF. The end of the stream is represented by a header denoting a 0 length and two CRLFs.</p> <p><strong>Note:</strong> despite the example, you actually do <strong>not</strong> need it in a JSP/Servlet based webapplication. Whenever the content length is not set on a response, the webcontainer will automatically transfer them in chunks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload