Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>URLConnection</code> buffers by default <em>everything</em> which is been written to its <code>getOutputStream()</code> in client's memory until it's closed. This is mandatory because the HTTP <code>Content-Length</code> response header needs to be set. But the content length is only known once all bytes have been written. This may be memory hogging when the response body is relatively large.</p> <p>If you know beforehand the exact amount of bytes (note: bytes, not characters) being written, then you could use <code>setFixedLengthStreamingMode()</code> to set it with <strong>exactly</strong> that amount of bytes, so that the <code>Content-Length</code> header could be set much sooner and so that <code>URLConnection</code> can flush more often. In your particular case, you apparently used the wrong value.</p> <p>The <code>setChunkedStreamingMode()</code> basically changes the transfer encoding to <code>chunked</code>. This is basically one line with the byte length in hexcode and then one line of written bytes therafter and then a blank line (see also <a href="http://en.wikipedia.org/wiki/Chunked_transfer_encoding" rel="nofollow noreferrer">wikipedia</a>). The last line has a byte length of 0 and so the server knows when it's the end of the body so that it doesn't have to wait for any incoming data. This allows the response body being flushed more often. You should only not set it with 0, but with a sensible value, such as 1000 or so. This way every 1000 written bytes will be sent as a new chunk.</p> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests/2793153#2793153">Using java.net.URLConnection to fire and handle HTTP requests</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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