I am a ruby newbie and tried to use a http client to send the XML HTTP
POST request to my cgi,
I thought I can get the text I input in the HTTP POST directly from the
$stdin as a string in cgi and extract the data out. but it didn't seem
to work.
I tried to do $stdin.realines to parse every line of the $stdin but I
got nothing out of it.
Are you using the cgi library from the stdlib?
If so, it reads the params from $stdin and gives you access to them
as a hash. Take a look at this example:
It takes care of GET and POST parsing either the query string or the
POST body for you.
Hope this helps,
Jesus.
···
On Fri, Apr 29, 2011 at 10:46 PM, Ting Chang <aumart@gmail.com> wrote:
Hello Ruby Masters,
I am a ruby newbie and tried to use a http client to send the XML HTTP
POST request to my cgi,
I thought I can get the text I input in the HTTP POST directly from the
$stdin as a string in cgi and extract the data out. but it didn't seem
to work.
I tried to do $stdin.realines to parse every line of the $stdin but I
got nothing out of it.
On Sat, Apr 30, 2011 at 05:46:50AM +0900, Ting Chang wrote:
Hello Ruby Masters,
I am a ruby newbie and tried to use a http client to send the XML HTTP
POST request to my cgi,
I thought I can get the text I input in the HTTP POST directly from the
$stdin as a string in cgi and extract the data out. but it didn't seem
to work.
I tried to do $stdin.realines to parse every line of the $stdin but I
got nothing out of it.
I am using this tool: http://soft-net.net/SendHTTPTool.aspx
and simply post Text input with the Method and URL specified only.
And the text content I input is:.
Sorry about misleading, I think my problem is that I cannot get any POST
data in my CGI, I tried your suggestion above and looks like the POST
data did not come through.
do you know what's possibly the reason?
or do you have any format recommend in the POST data? the only thing
that matter to me is to get the url data so my cgi script can take that
url to do the rest of the work.
I am using this tool: http://soft-net.net/SendHTTPTool.aspx
and simply post Text input with the Method and URL specified only.
And the text content I input is:.
Post data is sent to the server as name/value pairs. Maybe your
software interpretes that xml as an instruction to send a request to www.xxxurl.com, with the name/value pairs of DATA_TYPE=IMAGE.
Sorry about misleading, I think my problem is that I cannot get any POST
data in my CGI, I tried your suggestion above and looks like the POST
data did not come through.
do you know what's possibly the reason?
or do you have any format recommend in the POST data? the only thing
that matter to me is to get the url data so my cgi script can take that
url to do the rest of the work.
require 'cgi'
cgi = CGI.new
cgi.params.each_pair {|k,v| puts k + ' => ' + v }
That should tell you exactly what parameter keys and values are being
sent to your Ruby script. If you're actually viewing the output in the
browser, you might want to try adding some markup:
On Sat, Apr 30, 2011 at 09:21:55AM +0900, Ting Chang wrote:
Sorry about misleading, I think my problem is that I cannot get any POST
data in my CGI, I tried your suggestion above and looks like the POST
data did not come through.
do you know what's possibly the reason?
or do you have any format recommend in the POST data? the only thing
that matter to me is to get the url data so my cgi script can take that
url to do the rest of the work.
Sorry about misleading, I think my problem is that I cannot get any POST
data in my CGI, I tried your suggestion above and looks like the POST
data did not come through.
do you know what's possibly the reason?
Do you have to use that request software? You can easily test whether
your server's cgi gateway is working by using a ruby script to send the
post request to your cgi script: