title: Setting "Content-Length" header for large HTTP responses
body: <p>I have a use case where I have HTTP responses that need to be sent out. The default behaviour as I understand is, that if the servlet engine is able buffer the whole response into it's buffer, it sets the <code>Content-Length</code> header equal to the size of the message, but in case it cannot, it goes ahead and sets <code>Transfer-Encoding</code> equal to <code>Chunked</code>. The size limit on which this is done is <code>8KB</code>. So, messages less than 8KB have <code>Content-Length</code> and others have <code>Transfer-Encoding</code>.</p>
  <p>Now, I have a case where the HTTP response can be of 100s of MBs and I need to set <code>Content-Length</code> correctly, in order for the receiver to show a progress bar. So, my question is:</p>
  <p>If the servlet buffer size is 8KB and for a 100MB response I set &quot;Content-Length&quot;, does the servlet buffer the complete 100MB in memory before sending out the HTTP response? How is such a big message sent out when <code>chunked</code> is not set? Since, my current understanding is that both <code>Content-Length</code> and <code>chunked</code> cannot coexist.</p>