Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LWP::Parallel::UserAgent and POST

Status
Not open for further replies.

DavidJohnson

Programmer
Aug 6, 2002
7
DE
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::parallel::UserAgent;
use HTTP::Request;

my $url = "
my $reqs = [
HTTP::Request->new('GET', $url),
HTTP::Request->new('GET', $url."homes/marclang/"),
];

my $pua = LWP::parallel::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";
}
 
Um, what does 'doesn't work' mean? Here is an example of how to use POST and pass some arguments
Code:
my $req = HTTP::Request->new(POST => $url, undef, "name=$name&from=$from");
If that doesn't answer your question then you will have to be more specific about what your problem is.

jaa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top