summaryrefslogtreecommitdiff
path: root/cpan/HTTP-Tiny
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2012-12-27 21:43:42 +0000
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2012-12-27 21:43:42 +0000
commitd72a6fbd28855c4fdeaebdfb8a420addd1751e8b (patch)
tree94b3b87173539743b4c558c89f3a666d99322924 /cpan/HTTP-Tiny
parentb33c0c7199fc122a21f9e2338c8a0284ae9de754 (diff)
downloadperl-d72a6fbd28855c4fdeaebdfb8a420addd1751e8b.tar.gz
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]
Diffstat (limited to 'cpan/HTTP-Tiny')
-rw-r--r--cpan/HTTP-Tiny/lib/HTTP/Tiny.pm17
-rw-r--r--cpan/HTTP-Tiny/t/003_agent.t33
2 files changed, 45 insertions, 5 deletions
diff --git a/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm b/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm
index 463a6c3226..333aab56f7 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<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
index 0000000000..274917d2da
--- /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',
+ ;
+}