[Twisted-Python] http.Request and JSON

Gerrat gerrat1 at yahoo.com
Wed Jan 25 08:28:13 EST 2012

Tristan Seligmann <mithrandi <at> mithrandi.net> writes:

> On Tue, Jun 30, 2009 at 10:44 AM, Reza Lotun<rlotun <at> gmail.com> wrote:
> > To be safer, I do a request.content.getvalue() since content is a
> > cStringIO object and you can never be sure if somewhere along the
> > chain of processing someone hasn't done a .read and forgot to do a
> > .seek(0,0).
> You should probably do the seek/read instead, since I don't believe
> this is guaranteed to be a cStringIO; it might be an actual file on
> disk, or something else.

Thank You!!!

Every <stupid> example I've seen used "request.content.getvalue()" ...which
fails miserably for me (possibly because I'm on 64bit windows - but cStringIO is
available, so I'm not sure why it's not used).  request.content.read() works
wonderfully.  The "getvalue" method looked familiar, but I couldn't recall where
I'd seen it - only that *my* request.content doesn't have a getvalue method.  It
took quite a few searches before I stumbled on your comment here which gave me
the correct solution.

More information about the Twisted-Python mailing list