Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WWW-Curl-Simple CPAN distribution.

Report information
The Basics
Id: 46293
Status: rejected
Priority: 0/
Queue: WWW-Curl-Simple

People
Owner: andreas.marienborg [...] gmail.com
Requestors: jmmills@cpan.org (no email address)
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.03
Fixed in: (no value)



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
On Fri May 22 00:20:24 2009, JMMILLS wrote: Show quoted text
> 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: Show quoted text
> > 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
First of all, sorry for the incredibly late response! It seems RT decided to not send me email for new bugs, and I don't log in to check that often it seems. The code lives on github: http://github.com/omega/www-curl-simple I'll try to fix the issue now and hopefully push a new release
Ok, I have added this to github now. Could you check if this is working the way you want now?
No answer for a while, this code has been on CPAN in the last few releases