Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Don't send the content length and send the output as you derive it. You don't need to know the size of the output if you simply don't send the Content-Length header. That way can send part of the response before you have computed the rest of it.</p> <pre><code>def application(environ, start_response): status = '200 OK' output = 'Hello World!' response_headers = [('Content-type', 'text/html')] start_response(status, response_headers) yield head() yield part1() yield part2() yield part3() yield "&lt;!-- bye now! --&gt;" </code></pre> <p>Otherwise you will get no benefit from sending in chunks, since computing the output is probably the slow part and the internet protocol will send the output in chunks anyway.</p> <p>Sadly, this doesn't work in the case where, for example, the calculation of part2() decides you really need to change a header (like a cookie) or need to build other page-global data structures -- if this ever happens, you need to compute the entire output before sending the headers, and might as well use a <code>return [output]</code></p> <p>For example <a href="http://aaron.oirt.rutgers.edu/myapp/docs/W1200_1200.config_template" rel="nofollow noreferrer"> <a href="http://aaron.oirt.rutgers.edu/myapp/docs/W1200_1200.config_template" rel="nofollow noreferrer">http://aaron.oirt.rutgers.edu/myapp/docs/W1200_1200.config_template</a></a> Needs to build a page global data structure for the links to subsections that show at the top of the page -- so the last subsection must be rendered before the first chunk of output is delivered to the client.</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