Update HTTP-Tiny to CPAN version 0.025
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Thu, 27 Dec 2012 21:43:42 +0000 (21:43 +0000)
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Thu, 27 Dec 2012 21:43:42 +0000 (21:43 +0000)
  [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
Porting/Maintainers.pl
cpan/HTTP-Tiny/lib/HTTP/Tiny.pm
cpan/HTTP-Tiny/t/003_agent.t [new file with mode: 0644]

index f6ba34c..a283b90 100644 (file)
--- 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
index cee6430..5265b49 100755 (executable)
@@ -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',
index 463a6c3..333aab5 100644 (file)
@@ -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<agent>
 
-A user-agent string (defaults to 'HTTP::Tiny/$VERSION')
+A user-agent string (defaults to 'HTTP-Tiny/$VERSION'). If C<agent> 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 (file)
index 0000000..274917d
--- /dev/null
@@ -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',
+        ;
+}