DavidJohnson
Programmer
My question is how I can do the below example
with POST instead of GET? I want to use some
variables like: name=$name&from=$from
In the test script below I could add them in
this line "HTTP::Request->new('GET', $url),"
But when I use POST it doesn't work...
I don't have to use this example but I want
to be able to use multiple requests and POST...
Any ideas?
PS, This is not my script but it's about the same...
require LWP:
arallel::UserAgent;
use HTTP::Request;
my $url = "
my $reqs = [
HTTP::Request->new('GET', $url),
HTTP::Request->new('GET', $url."homes/marclang/"
,
];
my $pua = LWP:
arallel::UserAgent->new();
$pua->in_order (1); # handle requests in order of registration
$pua->duplicates(0); # ignore duplicates
$pua->timeout (2); # in seconds
$pua->redirect (1); # follow redirects
foreach my $req (@$reqs) {
print "Registering '".$req->url."'\n";
if ( my $res = $pua->register ($req) ) {
print STDERR $res->error_as_HTML;
}
}
my $entries = $pua->wait();
foreach (keys %$entries) {
my $res = $entries->{$_}->response;
print "Answer for '",$res->request->url, "' was \t", $res->code,": ",
$res->message,"\n";
}
with POST instead of GET? I want to use some
variables like: name=$name&from=$from
In the test script below I could add them in
this line "HTTP::Request->new('GET', $url),"
But when I use POST it doesn't work...
I don't have to use this example but I want
to be able to use multiple requests and POST...
Any ideas?
PS, This is not my script but it's about the same...
require LWP:
use HTTP::Request;
my $url = "
my $reqs = [
HTTP::Request->new('GET', $url),
HTTP::Request->new('GET', $url."homes/marclang/"
];
my $pua = LWP:
$pua->in_order (1); # handle requests in order of registration
$pua->duplicates(0); # ignore duplicates
$pua->timeout (2); # in seconds
$pua->redirect (1); # follow redirects
foreach my $req (@$reqs) {
print "Registering '".$req->url."'\n";
if ( my $res = $pua->register ($req) ) {
print STDERR $res->error_as_HTML;
}
}
my $entries = $pua->wait();
foreach (keys %$entries) {
my $res = $entries->{$_}->response;
print "Answer for '",$res->request->url, "' was \t", $res->code,": ",
$res->message,"\n";
}