in reply to Re^9: How to parse URL in CGI.pm
in thread How to parse URL in CGI.pm

The problem is that the query_string in CGI.pm doesn't give my the required string and I need to parse it by myself

I understood that the way of doing it is to look for the ENV.

My question is:

Is there an ENV which gives my the message body in case of a POST request?

Thanks!

Replies are listed 'Best First'.
Re^11: How to parse URL in CGI.pm
by ikegami (Patriarch) on Dec 07, 2010 at 17:03 UTC

    You should have no problem with CGI for POST unless you're being given garbage (e.g. being told you are provided something's that "application/x-www-form-urlencoded" when it isn't).

    my $url; if ($cgi->request_method eq 'GET') { # Can't use ->param('url') because the client is # providing the parameters in a stupid format. ( $url = $ENV{QUERY_STRING} ) =~ s/^.*[?&]url=//s; } else { $url = $cgi->param('url'); }

    If you are getting garbage, it can be handled. You've been given the link to the CGI spec. Read it. Your asking questions with no apparent effort at answering them yourself.

Re^11: How to parse URL in CGI.pm
by JavaFan (Canon) on Dec 07, 2010 at 16:46 UTC
    Are you sure it's CGI.pm that messes up the query_string, or happens this already at the user agent?
    Is there an ENV which gives my the message body in case of a POST request?
    A few seconds with the CGI.pm manual page reveals:
           If POSTed data is not of type application/x-www-form-urlencoded or
           multipart/form-data, then the POSTed data will not be processed, but
           instead be returned as-is in a parameter named POSTDATA.  To retrieve
           it, use code like this:
    
              my $data = $query->param('POSTDATA');
    
    You could have found this out for yourself.

    But if it's CGI.pm that is causing you all this grief, consider not using CGI.pm. Using the CGI protocol (which is different from CGI.pm!), you get the POST data on STDIN.