A straightforward use of a series of request.write()s with a request.finish() in the render_GET() method of a resource defaults to chunked encoding. I can avoid the chunked encoding by computing the entire response first using a StringIO (as shown below) and explicitly putting the "Content-Length" header in myself.<div>
<br></div><div>Is this the best (or recommended) way to create such a response?</div><div><br></div><div>Thx - Tom</div><div><br></div><div>=============</div><div><br></div><div>class myresource(Resource):</div><div><br>
</div><div> def render_GET(self, response):</div><div> output = StringIO.StringIO()</div><div> output.write("...")</div><div> output.write("...")</div><div> ...</div><div><br></div><div> data = output.getvalue()</div>
<div> output.close()</div><div><br></div><div> # Write the response data. "content-length" suppresses chunked coding</div><div><div> request.setHeader('content-length', len(data))</div><div> request.write(data)</div>
<div> request.finish()</div><div> return True</div></div><div><br></div>