develooper Front page | perl.libwww | Postings from February 2003

LWP::Parallel::UserAgent and cookies

From:
Ashish Mukherjee
Date:
February 19, 2003 12:13
Subject:
LWP::Parallel::UserAgent and cookies
Message ID:
3E532A08.B175D8F6@jobsahead.com
Hello everyone!

I have a question about LWP::Parallel::UserAgent and cookie jars using
HTTP::Cookies.
Can I use cookie jars with LWP::Parallel::UserAgent? Can it be used in
the same way as I do with LWP::UserAgent?

I have a script whick I know definitely works because I can see the
cookies being stored in the cookies.txt file.

use LWP::UserAgent;
require HTTP::Cookies;

my $jar = new HTTP::Cookies(file => 'cookies.txt', autosave =>  1);

my $ua = new LWP::UserAgent;
$ua->cookie_jar( $jar );

for (1 .. 10)
{
    my $req = new
HTTP::Request(GET => 'http://www.something.com/index.html');
    $ua->request($req);
}

However, when I do the same with LWP::Parallel::UserAgent as in the
script below, nothing gets saved to the cookies.txt file:

use LWP::Parallel::UserAgent;
require HTTP::Cookies;

my $jar = new HTTP::Cookies(file => 'cookies.txt', autosave =>  1);

my $ua = new LWP::Parallel::UserAgent;
$ua->cookie_jar( $jar );

for (1 .. 10)
{
    my $req = new
HTTP::Request(GET => 'http://www.something.com/index.html');
    $ua->register($req);
    $ua->wait(100);
}

Can someone please shed some light on how the 2 modules treat
cookies/cookie jars differently?

Regards,
Ashisih




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About