Subject: | add_request returns incorrect array index - possible new features? |
First great package, makes for really easy parallel fetching of http
content.
WWW::Curl::Simple->add_request returns the incorrect array index for
WWW::Curl::Simple->requests array collection.
Example
amelia:~ $ re.pl
$ use WWW::Curl::Simple;
$ my $curl = WWW::Curl::Simple->new();
$WWW_Curl_Simple1 = WWW::Curl::Simple=HASH(0x23ae820);
$ use HTTP::Request;
$ my @r = map { $curl->add_request(HTTP::Request->new(GET => $_)) }
qw[http://localhost/ http://localhost/sample1.xml];
$ARRAY1 = [
1,
2
];
$ ($curl->requests)[0]->request->url
http://localhost/
$
As you can see the request index item '0' is the first HTTP::Request
handle I added - how ever add_request return an index of '1'.
This a bit confusing when trying to clean up performed requests (mostly
useful in a fork() code).
It would be nice to see add_request return the
WWW::Curl::Simple::Request instance created and an addition
'has_request' and 'delete_request' collection methods for simple code like:
my @reqs = $curl->add_handles(@http_requests);
my @res = $curl->perform();
# clean up already performed requests
foreach(@reqs) {
$curl->delete_request($_) if $curl->has_request($_);
}
If you want I could roll up a patch to update/fix this behavior?
Git repository?
Thanks,
Jason