2
votes

hi i have a mobile client (a geofencing app), which will send triggered a HTTP Request (POST). This will be fetched by a perl script on my web server.

At the moment i dont know how the structure of the HTTP Request. how i can fetch the full HTTP Request with perl to analyse it? Guess the best way is to dump the request to a file.

as far as i understand the CGI, for handling a HTTP POST Request i need to give the object names, but i dont know them. Is there a way to dump the full Request?

1

1 Answers

3
votes

The CGI script doesn't receive the HTTP request. If you want to dump the form data received by a CGI script, you can use the following:

use CGI          qw( );
use Data::Dumper qw( Dumper );

my $cgi = CGI->new();
my %form;
for my $param ($cgi->param()) {
   $form{$param} = [ $cgi->param($param) ];
}

print($cgi->header('text/plain'));

local $Data::Dumper::Indent   = 1;
local $Data::Dumper::Sortkeys = 1;
local $Data::Dumper::Useqq    = 1;
print(Dumper(\%form));