WEBrick and Binary POST Data

G

Gianni Jacklone

Greetings Rubyists:

Quick question about WEBrick: Is there a way to get at the raw post data
from a post request, much like the var $HTTP_RAW_POST_DATA in php, and
request.getInputStream() from Java?

Is this just request.body in WEBrick?

Many thanks,
Gianni
 
M

Martin Pirker

Gianni Jacklone said:
Quick question about WEBrick: Is there a way to get at the raw post data
from a post request, much like the var $HTTP_RAW_POST_DATA in php, and
request.getInputStream() from Java?


ruby-talk 94785

helps?


Martin
 
G

Gianni Jacklone

Martin said:
ruby-talk 94785

helps?


Martin
I'm having trouble interpretting it. At the top of the message it says
"Request body is not read from socket when servlets are started." Then
soon after it says "But HTTPServer is going to read the body before
sending response".

The example code shows a custom servlet using req.query["data"] where
"data" was the name of the file input type.

So I derive from AbstractServlet and use req.query["data"] to get at the
raw post data for a form element. Am I correct?

In my particular case however, I am after the entire body of the POST,
my WEBrick servlet receives a POST request of binary data from an
external agent, and I need to get the raw binary data and parse it futher..

From my tests, where I derive a custom servlet and in do_Post I use
request.body, it seems to give me the raw POST data. Perhaps I am wrong
in this thinking however?

Thanks for helping me out, am I missing something?

Gianni
 
E

Eric Hodel

--Pgaa2uWPnPrfixyx
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Martin Pirker wrote:
=20
ruby-talk 94785

I'm having trouble interpretting it. At the top of the message it says=20
"Request body is not read from socket when servlets are started." Then=20
soon after it says "But HTTPServer is going to read the body before=20
sending response".
=20
The example code shows a custom servlet using req.query["data"] where=20
"data" was the name of the file input type.
=20
So I derive from AbstractServlet and use req.query["data"] to get at the= =20
raw post data for a form element. Am I correct?
Yes.

In my particular case however, I am after the entire body of the POST,=20
my WEBrick servlet receives a POST request of binary data from an=20
external agent, and I need to get the raw binary data and parse it futher=
..

Why don't you use multipart/form-data on the sending end? (You have no
control over it?)
From my tests, where I derive a custom servlet and in do_Post I use=20
request.body, it seems to give me the raw POST data. Perhaps I am wrong= =20
in this thinking however?

This should work.=20

--=20
Eric Hodel - (e-mail address removed) - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04


--Pgaa2uWPnPrfixyx
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQFBBnv8MypVHHlsnwQRAlBlAKCKDjXPUB5AFL+vruAQti3Hz6CGNACgtcxM
Lz41V4GAfa+lfOZKa5pZf3o=
=aW6L
-----END PGP SIGNATURE-----

--Pgaa2uWPnPrfixyx--
 
G

Gianni Jacklone

Eric said:
Gianni Jacklone ([email protected]) wrote:


Martin Pirker wrote:


Quick question about WEBrick: Is there a way to get at the raw post data


from a post request, much like the var $HTTP_RAW_POST_DATA in php, and


request.getInputStream() from Java?


ruby-talk 94785
I'm having trouble interpretting it. At the top of the message it says
"Request body is not read from socket when servlets are started." Then
soon after it says "But HTTPServer is going to read the body before
sending response".

The example code shows a custom servlet using req.query["data"] where
"data" was the name of the file input type.

So I derive from AbstractServlet and use req.query["data"] to get at the
raw post data for a form element. Am I correct?


Yes.



In my particular case however, I am after the entire body of the POST,
my WEBrick servlet receives a POST request of binary data from an
external agent, and I need to get the raw binary data and parse it futher..

Why don't you use multipart/form-data on the sending end? (You have no
control over it?)
I do not. The POST is from a Flash Application, I am writing a Flash
Remoting Gateway for Ruby.
This should work.

It appears it does. Thanks for the help, much appreciated.
==
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,149
Messages
2,570,842
Members
47,388
Latest member
EarthaGilm

Latest Threads

Top