Re: Best way to avoid chunked encoding in HTTP Resource response?

Ivan Kozik <[email protected]>
Newsgroups gmane.comp.python.twisted.web
Message-ID <CAKynti+uF+EVqR6wr-_egHY=P2u1L5VVsyRwCGWsNK9ye+-biw@mail.gmail.com>
On Thu, Apr 19, 2012 at 15:37, Tom Sheffler <[email protected]> wrote:
> Is this the best (or recommended) way to create such a response?

I don't think there's any need to close your StringIO.  You can also
use cStringIO.StringIO for better performance.  And you can just
return a string from your render_GET.  So, like this (untested):

 def render_GET(self, response):
    output = cStringIO.StringIO()
    output.write("...")
    output.write("...")
    return output.getvalue()

Ivan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.