diff -Nru libhttp-async-perl-0.29/Changes libhttp-async-perl-0.30/Changes --- libhttp-async-perl-0.29/Changes 2015-05-30 10:30:42.000000000 +0000 +++ libhttp-async-perl-0.30/Changes 2015-09-28 16:11:45.000000000 +0000 @@ -1,5 +1,9 @@ CHANGES to HTTP::Async +0.30 2015/05/30 + * Allow max_redirect or max_redirects, to be consistent with LWP::UserAgent + Thanks Vincent Lequertier (SkySymbol)! + 0.29 2015/05/30 * Make add_with_opts throw error on invalid options diff -Nru libhttp-async-perl-0.29/debian/changelog libhttp-async-perl-0.30/debian/changelog --- libhttp-async-perl-0.29/debian/changelog 2015-05-30 19:50:12.000000000 +0000 +++ libhttp-async-perl-0.30/debian/changelog 2015-10-18 14:51:51.000000000 +0000 @@ -1,3 +1,11 @@ +libhttp-async-perl (0.30-1) unstable; urgency=medium + + * Team upload. + * Import upstream version 0.30. + * Bump debhelper compatibility level to 9. + + -- gregor herrmann Sun, 18 Oct 2015 16:51:41 +0200 + libhttp-async-perl (0.29-1) unstable; urgency=medium * Team upload diff -Nru libhttp-async-perl-0.29/debian/compat libhttp-async-perl-0.30/debian/compat --- libhttp-async-perl-0.29/debian/compat 2015-05-30 19:20:10.000000000 +0000 +++ libhttp-async-perl-0.30/debian/compat 2015-10-18 14:51:51.000000000 +0000 @@ -1 +1 @@ -8 +9 diff -Nru libhttp-async-perl-0.29/debian/control libhttp-async-perl-0.30/debian/control --- libhttp-async-perl-0.29/debian/control 2015-05-30 19:50:12.000000000 +0000 +++ libhttp-async-perl-0.30/debian/control 2015-10-18 14:51:51.000000000 +0000 @@ -5,7 +5,7 @@ Daniel Lintott Section: perl Priority: optional -Build-Depends: debhelper (>= 8) +Build-Depends: debhelper (>= 9) Build-Depends-Indep: libnet-https-nb-perl, libtest-fatal-perl, libtest-http-server-simple-perl, diff -Nru libhttp-async-perl-0.29/lib/HTTP/Async.pm libhttp-async-perl-0.30/lib/HTTP/Async.pm --- libhttp-async-perl-0.29/lib/HTTP/Async.pm 2015-05-30 10:29:30.000000000 +0000 +++ libhttp-async-perl-0.30/lib/HTTP/Async.pm 2015-09-28 16:12:04.000000000 +0000 @@ -3,7 +3,7 @@ package HTTP::Async; -our $VERSION = '0.29'; +our $VERSION = '0.30'; use Carp; use Data::Dumper; @@ -84,7 +84,7 @@ slots: 20 timeout: 180 (seconds) max_request_time: 300 (seconds) - max_redirects: 7 + max_redirect: 7 poll_interval: 0.05 (seconds) proxy_host: '' proxy_port: '' @@ -95,6 +95,9 @@ peer_addr: '' If defined, is expected to be similar to C, with extract_cookies and add_cookie_header methods. + +The option max_redirects has been renamed to max_redirect to be consistent with LWP::UserAgent, although max_redirects still works. + =head1 METHODS @@ -113,7 +116,7 @@ opts => { slots => 20, - max_redirects => 7, + max_redirect => 7, timeout => 180, max_request_time => 300, poll_interval => 0.05, @@ -144,7 +147,7 @@ sub _next_id { return ++$_[0]->{current_id} } -=head2 slots, timeout, max_request_time, poll_interval, max_redirects, proxy_host, proxy_port, local_addr, local_port, ssl_options, cookie_jar, peer_addr +=head2 slots, timeout, max_request_time, poll_interval, max_redirect, proxy_host, proxy_port, local_addr, local_port, ssl_options, cookie_jar, peer_addr $old_value = $async->slots; $new_value = $async->slots( $new_value ); @@ -157,7 +160,7 @@ =cut my %GET_SET_KEYS = map { $_ => 1 } qw( slots poll_interval - timeout max_request_time max_redirects + timeout max_request_time max_redirect proxy_host proxy_port local_addr local_port ssl_options cookie_jar peer_addr); sub _add_get_set_key { @@ -166,10 +169,15 @@ $GET_SET_KEYS{$key} = 1; } +my %KEY_ALIASES = ( max_redirects => 'max_redirect' ); + sub _get_opt { my $self = shift; my $key = shift; my $id = shift; + + $key = $KEY_ALIASES{$key} if exists $KEY_ALIASES{$key}; + die "$key not valid for _get_opt" unless $GET_SET_KEYS{$key}; # If there is an option set for this id then use that, otherwise fall back @@ -184,6 +192,9 @@ sub _set_opt { my $self = shift; my $key = shift; + + $key = $KEY_ALIASES{$key} if exists $KEY_ALIASES{$key}; + die "$key not valid for _set_opt" unless $GET_SET_KEYS{$key}; $self->{opts}{$key} = shift if @_; return $self->{opts}{$key}; @@ -881,7 +892,7 @@ $entry->{finish_by} = $time + $self->_get_opt( 'max_request_time', $id ); $entry->{handle} = $s; - $entry->{redirects_left} = $self->_get_opt( 'max_redirects', $id ) + $entry->{redirects_left} = $self->_get_opt( 'max_redirect', $id ) unless exists $entry->{redirects_left}; return 1; diff -Nru libhttp-async-perl-0.29/MANIFEST libhttp-async-perl-0.30/MANIFEST --- libhttp-async-perl-0.29/MANIFEST 2015-05-30 10:32:20.000000000 +0000 +++ libhttp-async-perl-0.30/MANIFEST 2015-09-28 16:13:01.000000000 +0000 @@ -8,11 +8,15 @@ t/bad-connections.t t/bad-headers.t t/bad-hosts.t +t/cookies.t t/dead-connection.t t/headers.t +t/invalid-options.t +t/key_aliases.t t/local-addr.t t/make-url-absolute.t t/not-modified.t +t/peer-addr.t t/pod-coverage.t t/pod.t t/polite.t @@ -22,13 +26,13 @@ t/real-servers.t t/redirects.t t/release-cpan-changes.t +t/remove.t t/setup.t t/strip-host-from-uri.t t/template.t t/test-utils.pl t/TestServer.pm t/timeout.t -t/invalid-options.t TODO META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) diff -Nru libhttp-async-perl-0.29/META.json libhttp-async-perl-0.30/META.json --- libhttp-async-perl-0.29/META.json 2015-05-30 10:32:20.000000000 +0000 +++ libhttp-async-perl-0.30/META.json 2015-09-28 16:13:01.000000000 +0000 @@ -4,7 +4,7 @@ "unknown" ], "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.143240", + "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.142690", "license" : [ "perl_5" ], @@ -59,5 +59,5 @@ "url" : "https://github.com/evdb/HTTP-Async" } }, - "version" : "0.29" + "version" : "0.30" } diff -Nru libhttp-async-perl-0.29/META.yml libhttp-async-perl-0.30/META.yml --- libhttp-async-perl-0.29/META.yml 2015-05-30 10:32:20.000000000 +0000 +++ libhttp-async-perl-0.30/META.yml 2015-09-28 16:13:01.000000000 +0000 @@ -7,7 +7,7 @@ configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.143240' +generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.142690' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -38,4 +38,4 @@ URI::Escape: '0' resources: repository: https://github.com/evdb/HTTP-Async -version: '0.29' +version: '0.30' diff -Nru libhttp-async-perl-0.29/t/cookies.t libhttp-async-perl-0.30/t/cookies.t --- libhttp-async-perl-0.29/t/cookies.t 1970-01-01 00:00:00.000000000 +0000 +++ libhttp-async-perl-0.30/t/cookies.t 2014-11-17 15:59:35.000000000 +0000 @@ -0,0 +1,32 @@ +use strict; +use warnings; + +use Test::More tests => 4; +use HTTP::Request; +use HTTP::Cookies; +use HTTP::Async; + +require 't/TestServer.pm'; +my $s = TestServer->new(); +my $url_root = $s->started_ok("starting a test server"); + +my $q = HTTP::Async->new; + +my $cookie_jar = HTTP::Cookies->new({}); +$q->cookie_jar($cookie_jar); + +# Receive a cookie and store it in a cookie jar +{ + my $url = "$url_root/foo/bar?cookie=1"; + + my $req = HTTP::Request->new('GET', $url); + ok $q->add($req), "Added request to the queue"; + $q->poke while !$q->to_return_count; + + my $res = $q->next_response; + my $response_cookie = $res->header('Set-Cookie'); + ok $response_cookie =~ m/x=test/, "Got cookie in response '$response_cookie'"; + + my $jar_cookie = $cookie_jar->as_string(); + ok $jar_cookie =~ m/x=test/, "Got cookie from cookie jar '$jar_cookie'"; +} diff -Nru libhttp-async-perl-0.29/t/key_aliases.t libhttp-async-perl-0.30/t/key_aliases.t --- libhttp-async-perl-0.29/t/key_aliases.t 1970-01-01 00:00:00.000000000 +0000 +++ libhttp-async-perl-0.30/t/key_aliases.t 2015-09-28 16:02:27.000000000 +0000 @@ -0,0 +1,13 @@ + +use strict; +use warnings; + +use Test::More tests => 4; + +use HTTP::Async; + +foreach my $number ( 0, 3 ) { + my $q2 = HTTP::Async->new( max_redirects => $number ); + ok $q2, "created object"; + is $q2->max_redirect, $number, "got $number"; +} diff -Nru libhttp-async-perl-0.29/t/peer-addr.t libhttp-async-perl-0.30/t/peer-addr.t --- libhttp-async-perl-0.29/t/peer-addr.t 1970-01-01 00:00:00.000000000 +0000 +++ libhttp-async-perl-0.30/t/peer-addr.t 2015-06-02 06:27:03.000000000 +0000 @@ -0,0 +1,30 @@ +use strict; +use warnings; + +use Test::More; +use HTTP::Request; + +plan tests => 4; + +require 't/TestServer.pm'; +my $s = TestServer->new(); +my $url_root = $s->started_ok("starting a test server"); + +$url_root =~ s/localhost/example.org/; + +use HTTP::Async; + +my $q = HTTP::Async->new; + +my $req = HTTP::Request->new( 'GET', "$url_root?delay=0" ); + +my %opts = ( + peer_addr => 'localhost', +); +ok $q->add_with_opts($req, \%opts), "Added request to $url_root to the queue with peer_addr set to 'localhost'"; + +$q->poke while !$q->to_return_count; + +my $res = $q->next_response; +is $res->code, 200, "Got a response"; +like $res->content, qr/Delayed for/, "Got expected response"; diff -Nru libhttp-async-perl-0.29/t/redirects.t libhttp-async-perl-0.30/t/redirects.t --- libhttp-async-perl-0.29/t/redirects.t 2014-06-06 21:09:10.000000000 +0000 +++ libhttp-async-perl-0.30/t/redirects.t 2015-09-28 16:02:27.000000000 +0000 @@ -18,8 +18,8 @@ use HTTP::Async; my $q = HTTP::Async->new; -# Check that the max_redirects is at a sensible level. -is $q->max_redirects, 7, "max_redirects == 7"; +# Check that the max_redirect is at a sensible level. +is $q->max_redirect, 7, "max_redirect == 7"; # Send a request to somewhere that will redirect a certain number of # times: @@ -55,7 +55,7 @@ { # Set the max_redirect higher and try again. - ok $q->max_redirects(30), "Set the max_redirects higher."; + ok $q->max_redirect(30), "Set the max_redirect higher."; my $url = "$url_root?redirect=20"; my $req = HTTP::Request->new( 'GET', $url ); @@ -70,8 +70,8 @@ { # Set the max_redirect to zero and check that none happen. - is $q->max_redirects(0), 0, "Set the max_redirects to zero."; - is $q->max_redirects, 0, "max_redirects is set to zero."; + is $q->max_redirect(0), 0, "Set the max_redirect to zero."; + is $q->max_redirect, 0, "max_redirect is set to zero."; my $url = "$url_root?redirect=20"; my $req = HTTP::Request->new( 'GET', $url ); @@ -87,8 +87,8 @@ # Check that redirects have their headers repeated # Exmaple from kloevschall (https://github.com/evdb/HTTP-Async/issues/8) - is $q->max_redirects(1), 1, "Set the max_redirects to one."; - is $q->max_redirects, 1, "max_redirects is set to one."; + is $q->max_redirect(1), 1, "Set the max_redirect to one."; + is $q->max_redirect, 1, "max_redirect is set to one."; my $headers = HTTP::Headers->new(Accept => 'application/x-research-info-systems'); diff -Nru libhttp-async-perl-0.29/t/remove.t libhttp-async-perl-0.30/t/remove.t --- libhttp-async-perl-0.29/t/remove.t 1970-01-01 00:00:00.000000000 +0000 +++ libhttp-async-perl-0.30/t/remove.t 2014-11-17 15:59:35.000000000 +0000 @@ -0,0 +1,105 @@ +use strict; +use warnings; + +use Test::More tests => 21; + +use Data::Dumper; + +use HTTP::Request; +use HTTP::Async; + +## Set up - create an Async object with ten items in its queue + +require 't/TestServer.pm'; +# To ensure that remove and remove_all work on all three states, we need to +# have items in all three states when we call them. +# +# The three states are: to_send, in_progress, and to_return. +# +# We can create them by adding items which will run quickly, items which will +# trickle data slowly, and items which are not running. +# +# XXX we currently only test in_progress and to_return as items are hard to +# keep in the to_send queue, HTTP::Async is too good at moving them into the +# to_progress queue! +{ + my $s = TestServer->new(); + my $url_root = $s->started_ok("starting a test server"); + + my $q = HTTP::Async->new; + + is $q->total_count, 0, "total_count starts at zero"; + + my %type_to_id = populate_queues($q, $url_root); + + ## Remove - test remove() to remove a single item + + for my $type (sort keys %type_to_id) { + my $id = $type_to_id{$type}; + ok $q->remove($id), "removed '$type' item with id '$id'"; + } + + ok !$q->remove(123456), "removal of bad id '123456' returns false"; + + is $q->total_count, 0, "total_count is now zero"; +} + +{ + my $s = TestServer->new(); + my $url_root = $s->started_ok("starting a test server"); + + my $q = HTTP::Async->new; + + is $q->total_count, 0, "total_count starts at zero"; + + my %type_to_id = populate_queues($q, $url_root); + + ## Remove All - test remove_all() removes all queued items + + ok $q->remove_all, "removed all items"; + + ok !$q->remove_all, "remove_all() on empty queue returns false"; + + is $q->total_count, 0, "total_count is now zero"; +} + +############################################################################## + +sub populate_queues { + my $q = shift; + my $url_root = shift; + + my %type_to_id; + + # fast / to_return + { + my $url = "$url_root?trickle=1"; + my $req = HTTP::Request->new('GET', $url); + ok $type_to_id{'fast'} = $q->add($req), "added fast / to_return item"; + + for (1 .. 10) { + $q->poke; + last if $q->to_return_count; + sleep 1; + } + + if (!$q->to_return_count) { + diag Dumper $q; + } + + is $q->to_return_count, 1, "to_return_count is one"; + } + + # slow / in_progress + { + my $url = "$url_root?trickle=1000"; + my $req = HTTP::Request->new('GET', $url); + ok $type_to_id{'slow'} = $q->add($req), "added slow / in_progress item"; + $q->poke; + is $q->in_progress_count, 1, "in_progress_count is one"; + } + + is $q->total_count, 2, "total_count is now two"; + + return %type_to_id; +} diff -Nru libhttp-async-perl-0.29/t/setup.t libhttp-async-perl-0.30/t/setup.t --- libhttp-async-perl-0.29/t/setup.t 2013-03-29 08:50:55.000000000 +0000 +++ libhttp-async-perl-0.30/t/setup.t 2015-09-28 16:02:27.000000000 +0000 @@ -11,11 +11,11 @@ foreach my $number ( 0, 3 ) { my $q1 = $class->new; - is $q1->max_redirects($number), $number, "set to $number"; - is $q1->max_redirects, $number, "got $number"; + is $q1->max_redirect($number), $number, "set to $number"; + is $q1->max_redirect, $number, "got $number"; - my $q2 = $class->new( max_redirects => $number ); + my $q2 = $class->new( max_redirect => $number ); ok $q2, "created object"; - is $q2->max_redirects, $number, "got $number"; + is $q2->max_redirect, $number, "got $number"; } }