env['jack.request.body']

0 views
Skip to first unread message

Tim Schaub

unread,
Aug 10, 2009, 5:09:34 PM8/10/09
to narw...@googlegroups.com
Hey-

If it doesn't belong in JSGI, is there a jack specific place in the env
for the request body?

Basically, I'm looking for a sensible way to get
env["jack.input"].read().decodeToString("utf-8") - but since the input
stream has already been read by the time my app has access to it, and
since I can't rewind it, I'm uncertain how to get the request body.

I know the body won't be a string in all cases. Though in cases other
than application/x-www-form-urlencoded and multipart/form-data, it seems
pretty handy to me to be able to get the request body as a string
(without dealing with rewinding the stream).

Thanks for any tips.

Tim

Dean Landolt

unread,
Aug 10, 2009, 5:30:30 PM8/10/09
to narw...@googlegroups.com

Grabbing the stream as string would probably be a great jack helper, but the request body _does_ belong in JSGI (as noted, in env["jack.input"]).

I recently emailed partially about this very problem -- it should probably be specified that the stream can be rewound, but it's not explicitly necessary (you could always pass in a new stream). In my case (narwhal inside persevere) persevere also doesn't provide an InputStream that is markSupported (in java terms, meaning, it's non-rewindable). Worse, it's rejected all of my attempts to generate a new stream for env["jack.input"], so I'm going to dust off my java and hack on the core a little.

In your case, once you accumulate your ByteString and decodeToString, you should be able to toss your wrap your bytes in a binary.BinaryIO and attach it to env["jack.input"]. Just a guess (I tried something like this in persevere to no avail, but I imagine there's a better shot of it working in narwhal).
Reply all
Reply to author
Forward
0 new messages