From d72a6fbd28855c4fdeaebdfb8a420addd1751e8b Mon Sep 17 00:00:00 2001 From: Chris 'BinGOs' Williams Date: Thu, 27 Dec 2012 21:43:42 +0000 Subject: [PATCH] Update HTTP-Tiny to CPAN version 0.025 [DELTA] 0.025 2012-12-26 12:09:43 America/New_York [ADDED] - Agent string appends default if it ends in a space, just like LWP [Chris Weyl] --- MANIFEST | 1 + Porting/Maintainers.pl | 2 +- cpan/HTTP-Tiny/lib/HTTP/Tiny.pm | 17 ++++++++++++----- cpan/HTTP-Tiny/t/003_agent.t | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 cpan/HTTP-Tiny/t/003_agent.t diff --git a/MANIFEST b/MANIFEST index f6ba34c..a283b90 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1169,6 +1169,7 @@ cpan/HTTP-Tiny/lib/HTTP/Tiny.pm cpan/HTTP-Tiny/t/000_load.t cpan/HTTP-Tiny/t/001_api.t cpan/HTTP-Tiny/t/002_croakage.t +cpan/HTTP-Tiny/t/003_agent.t cpan/HTTP-Tiny/t/00-compile.t cpan/HTTP-Tiny/t/010_url.t cpan/HTTP-Tiny/t/020_headers.t diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index cee6430..5265b49 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -971,7 +971,7 @@ use File::Glob qw(:case); 'HTTP::Tiny' => { 'MAINTAINER' => 'dagolden', - 'DISTRIBUTION' => 'DAGOLDEN/HTTP-Tiny-0.024.tar.gz', + 'DISTRIBUTION' => 'DAGOLDEN/HTTP-Tiny-0.025.tar.gz', 'FILES' => q[cpan/HTTP-Tiny], 'EXCLUDED' => [ 't/00-report-prereqs.t', diff --git a/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm b/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm index 463a6c3..333aab5 100644 --- a/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm +++ b/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm @@ -3,7 +3,7 @@ package HTTP::Tiny; use strict; use warnings; # ABSTRACT: A small, simple, correct HTTP/1.1 client -our $VERSION = '0.024'; # VERSION +our $VERSION = '0.025'; # VERSION use Carp (); @@ -21,13 +21,20 @@ BEGIN { sub new { my($class, %args) = @_; - (my $agent = $class) =~ s{::}{-}g; + + (my $default_agent = $class) =~ s{::}{-}g; + $default_agent .= "/" . ($class->VERSION || 0); + my $self = { - agent => $agent . "/" . ($class->VERSION || 0), + agent => $default_agent, max_redirect => 5, timeout => 60, verify_SSL => $args{verify_SSL} || $args{verify_ssl} || 0, # no verification by default }; + + $args{agent} .= $default_agent + if defined $args{agent} && $args{agent} =~ / $/; + for my $key ( @attributes ) { $self->{$key} = $args{$key} if exists $args{$key} } @@ -922,7 +929,7 @@ HTTP::Tiny - A small, simple, correct HTTP/1.1 client =head1 VERSION -version 0.024 +version 0.025 =head1 SYNOPSIS @@ -965,7 +972,7 @@ This constructor returns a new HTTP::Tiny object. Valid attributes include: C -A user-agent string (defaults to 'HTTP::Tiny/$VERSION') +A user-agent string (defaults to 'HTTP-Tiny/$VERSION'). If C ends in a space character, the default user-agent string is appended. =item * diff --git a/cpan/HTTP-Tiny/t/003_agent.t b/cpan/HTTP-Tiny/t/003_agent.t new file mode 100644 index 0000000..274917d --- /dev/null +++ b/cpan/HTTP-Tiny/t/003_agent.t @@ -0,0 +1,33 @@ +#!perl + +use strict; +use warnings; + +use Test::More tests => 3; +use HTTP::Tiny; + +# a couple tests to ensure that we get the default agent expected, the coorect +# agent when specified, and the correct agent when specifified with a space at +# the end of the string (as LWP::UserAgent does) + + +my $default = 'HTTP-Tiny/' . (HTTP::Tiny->VERSION || 0); + +{ + my $ua = HTTP::Tiny->new(); + is $ua->agent, $default, 'default agent string is as expected'; +} + +{ + my $ua = HTTP::Tiny->new(agent => 'something else'); + is $ua->agent, 'something else', 'agent string is as expected'; +} + +{ + my $ua = HTTP::Tiny->new(agent => 'something else '); + is + $ua->agent, + "something else $default", + 'agent string is as properly appended to', + ; +} -- 2.7.4