diff options
Diffstat (limited to 'cpan/HTTP-Tiny')
-rw-r--r-- | cpan/HTTP-Tiny/lib/HTTP/Tiny.pm | 16 | ||||
-rw-r--r-- | cpan/HTTP-Tiny/t/00-compile.t | 74 | ||||
-rw-r--r-- | cpan/HTTP-Tiny/t/150_post_form.t | 3 | ||||
-rw-r--r-- | cpan/HTTP-Tiny/t/cases/form-03.txt | 2 | ||||
-rw-r--r-- | cpan/HTTP-Tiny/t/cases/form-05.txt | 21 |
5 files changed, 34 insertions, 82 deletions
diff --git a/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm b/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm index 30ef26ce63..8932b19ae2 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.034'; # VERSION +our $VERSION = '0.035'; # VERSION use Carp (); @@ -189,7 +189,7 @@ sub www_form_urlencode { } } - return join("&", sort @terms); + return join("&", (ref $data eq 'ARRAY') ? (@terms) : (sort @terms) ); } #--------------------------------------------------------------------------# @@ -1008,7 +1008,7 @@ HTTP::Tiny - A small, simple, correct HTTP/1.1 client =head1 VERSION -version 0.034 +version 0.035 =head1 SYNOPSIS @@ -1142,7 +1142,9 @@ The C<success> field of the response will be true if the status code is 2XX. This method executes a C<POST> request and sends the key/value pairs from a form data hash or array reference to the given URL with a C<content-type> of -C<application/x-www-form-urlencoded>. See documentation for the +C<application/x-www-form-urlencoded>. If data is provided as an array +reference, the order is preserved; if provided as a hash reference, the terms +are sorted on key and value for consistency. See documentation for the C<www_form_urlencode> method for details on the encoding. The URL must have unsafe characters escaped and international domain names @@ -1299,8 +1301,10 @@ This method converts the key/value pairs from a data hash or array reference into a C<x-www-form-urlencoded> string. The keys and values from the data reference will be UTF-8 encoded and escaped per RFC 3986. If a value is an array reference, the key will be repeated with each of the values of the array -reference. The key/value pairs in the resulting string will be sorted by key -and value. +reference. If data is provided as a hash reference, the key/value pairs in the +resulting string will be sorted by key and value for consistent ordering. + +To preserve the order (r =for Pod::Coverage agent cookie_jar diff --git a/cpan/HTTP-Tiny/t/00-compile.t b/cpan/HTTP-Tiny/t/00-compile.t deleted file mode 100644 index 6454c8201e..0000000000 --- a/cpan/HTTP-Tiny/t/00-compile.t +++ /dev/null @@ -1,74 +0,0 @@ -#!perl - -use strict; -use warnings; - -use Test::More; - - - -use File::Find; -use File::Temp qw{ tempdir }; - -my @modules; -find( - sub { - return if $File::Find::name !~ /\.pm\z/; - my $found = $File::Find::name; - $found =~ s{^lib/}{}; - $found =~ s{[/\\]}{::}g; - $found =~ s/\.pm$//; - # nothing to skip - push @modules, $found; - }, - 'lib', -); - -sub _find_scripts { - my $dir = shift @_; - - my @found_scripts = (); - find( - sub { - return unless -f; - my $found = $File::Find::name; - # nothing to skip - open my $FH, '<', $_ or do { - note( "Unable to open $found in ( $! ), skipping" ); - return; - }; - my $shebang = <$FH>; - return unless $shebang =~ /^#!.*?\bperl\b\s*$/; - push @found_scripts, $found; - }, - $dir, - ); - - return @found_scripts; -} - -my @scripts; -do { push @scripts, _find_scripts($_) if -d $_ } - for qw{ bin script scripts }; - -my $plan = scalar(@modules) + scalar(@scripts); -$plan ? (plan tests => $plan) : (plan skip_all => "no tests to run"); - -{ - # fake home for cpan-testers - local $ENV{HOME} = tempdir( CLEANUP => 1 ); - - like( qx{ $^X -Ilib -e "require $_; print '$_ ok'" }, qr/^\s*$_ ok/s, "$_ loaded ok" ) - for sort @modules; - - SKIP: { - eval "use Test::Script 1.05; 1;"; - skip "Test::Script needed to test script compilation", scalar(@scripts) if $@; - foreach my $file ( @scripts ) { - my $script = $file; - $script =~ s!.*/!!; - script_compiles( $file, "$script script compiles" ); - } - } - -} diff --git a/cpan/HTTP-Tiny/t/150_post_form.t b/cpan/HTTP-Tiny/t/150_post_form.t index f9fbd17bbe..c1c231848f 100644 --- a/cpan/HTTP-Tiny/t/150_post_form.t +++ b/cpan/HTTP-Tiny/t/150_post_form.t @@ -33,7 +33,7 @@ for my $file ( dir_list("t/cases", qr/^form/ ) ) { my @params = split "\\|", $case->{content}[0]; my $formdata; - if ( $case->{datatype} eq 'HASH' ) { + if ( $case->{datatype}[0] eq 'HASH' ) { while ( @params ) { my ($key, $value) = splice( @params, 0, 2 ); if ( ref $formdata->{$key} ) { @@ -66,6 +66,7 @@ for my $file ( dir_list("t/cases", qr/^form/ ) ) { my $label = basename($file); + is( sort_headers($got_req), sort_headers($expect_req), "$label request" ); my ($rc) = $give_res =~ m{\S+\s+(\d+)}g; diff --git a/cpan/HTTP-Tiny/t/cases/form-03.txt b/cpan/HTTP-Tiny/t/cases/form-03.txt index b6dcd47e2e..101224df12 100644 --- a/cpan/HTTP-Tiny/t/cases/form-03.txt +++ b/cpan/HTTP-Tiny/t/cases/form-03.txt @@ -3,7 +3,7 @@ url content bar|baz|ack|foo datatype - ARRAY + HASH ---------- POST /new HTTP/1.1 Host: example.com diff --git a/cpan/HTTP-Tiny/t/cases/form-05.txt b/cpan/HTTP-Tiny/t/cases/form-05.txt new file mode 100644 index 0000000000..825604feb3 --- /dev/null +++ b/cpan/HTTP-Tiny/t/cases/form-05.txt @@ -0,0 +1,21 @@ +url + http://example.com/new +content + bar|baz|ack|foo +datatype + ARRAY +---------- +POST /new HTTP/1.1 +Host: example.com +Connection: close +User-Agent: HTTP-Tiny/VERSION +Content-Type: application/x-www-form-urlencoded +Content-Length: 15 + +bar=baz&ack=foo +---------- +HTTP/1.1 201 Created +Date: Thu, 03 Feb 1994 00:00:00 GMT +Location: http://example.com/new/01.txt +Content-Length: 0 + |