summaryrefslogtreecommitdiff
path: root/cpan
diff options
context:
space:
mode:
authorDavid Golden <dagolden@cpan.org>2011-07-18 16:54:59 -0400
committerDavid Golden <dagolden@cpan.org>2011-07-18 16:54:59 -0400
commit77ccfaeb2504f1318efe013cdc637b9886ea49f7 (patch)
tree0bf30c016807c7a1cd9b3890ef29317f0aab331d /cpan
parentf11ca51e41e898a77f1fd33b9e0371e69b1be73a (diff)
downloadperl-77ccfaeb2504f1318efe013cdc637b9886ea49f7.tar.gz
Upgraded HTTP-Tiny to CPAN version 0.013
0.013 2011-07-17 23:14:22 America/New_York [NEW FEATURES] - $ENV{http_proxy} support added [Claes Jakobsson] [OTHER] - Internal/private errors converted from "croak" to "die" as internal errors are caught by "eval"
Diffstat (limited to 'cpan')
-rw-r--r--cpan/HTTP-Tiny/lib/HTTP/Tiny.pm153
-rw-r--r--cpan/HTTP-Tiny/t/00-compile.t21
-rw-r--r--cpan/HTTP-Tiny/t/000_load.t8
-rw-r--r--cpan/HTTP-Tiny/t/001_api.t8
-rw-r--r--cpan/HTTP-Tiny/t/002_croakage.t8
-rw-r--r--cpan/HTTP-Tiny/t/010_url.t8
-rw-r--r--cpan/HTTP-Tiny/t/020_headers.t8
-rw-r--r--cpan/HTTP-Tiny/t/030_response.t8
-rw-r--r--cpan/HTTP-Tiny/t/040_content.t8
-rw-r--r--cpan/HTTP-Tiny/t/050_chunked_body.t8
-rw-r--r--cpan/HTTP-Tiny/t/060_http_date.t8
-rw-r--r--cpan/HTTP-Tiny/t/100_get.t8
-rw-r--r--cpan/HTTP-Tiny/t/110_mirror.t8
-rw-r--r--cpan/HTTP-Tiny/t/120_put.t8
-rw-r--r--cpan/HTTP-Tiny/t/130_redirect.t8
-rw-r--r--cpan/HTTP-Tiny/t/140_proxy.t35
-rw-r--r--cpan/HTTP-Tiny/t/Util.pm10
17 files changed, 127 insertions, 196 deletions
diff --git a/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm b/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm
index b4f6bd733c..135555366b 100644
--- a/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm
+++ b/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm
@@ -1,19 +1,8 @@
# vim: ts=4 sts=4 sw=4 et:
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
package HTTP::Tiny;
-BEGIN {
- $HTTP::Tiny::VERSION = '0.012';
-}
use strict;
use warnings;
-# ABSTRACT: A small, simple, correct HTTP/1.1 client
+our $VERSION = '0.013'; # VERSION
use Carp ();
@@ -40,6 +29,17 @@ sub new {
for my $key ( @attributes ) {
$self->{$key} = $args{$key} if exists $args{$key}
}
+
+ # Never override proxy argument as this breaks backwards compat.
+ if (!exists $self->{proxy} && (my $http_proxy = $ENV{http_proxy})) {
+ if ($http_proxy =~ m{\Ahttp://[^/?#:@]+:\d+/?\z}) {
+ $self->{proxy} = $http_proxy;
+ }
+ else {
+ Carp::croak(qq{Environment 'http_proxy' must be in format http://<host>:<port>/\n});
+ }
+ }
+
return bless $self, $class;
}
@@ -47,7 +47,7 @@ sub new {
sub get {
my ($self, $url, $args) = @_;
@_ == 2 || (@_ == 3 && ref $args eq 'HASH')
- or Carp::croak(q/Usage: $http->get(URL, [HASHREF])/);
+ or Carp::croak(q/Usage: $http->get(URL, [HASHREF])/ . "\n");
return $self->request('GET', $url, $args || {});
}
@@ -55,21 +55,21 @@ sub get {
sub mirror {
my ($self, $url, $file, $args) = @_;
@_ == 3 || (@_ == 4 && ref $args eq 'HASH')
- or Carp::croak(q/Usage: $http->mirror(URL, FILE, [HASHREF])/);
+ or Carp::croak(q/Usage: $http->mirror(URL, FILE, [HASHREF])/ . "\n");
if ( -e $file and my $mtime = (stat($file))[9] ) {
$args->{headers}{'if-modified-since'} ||= $self->_http_date($mtime);
}
my $tempfile = $file . int(rand(2**31));
open my $fh, ">", $tempfile
- or Carp::croak(qq/Error: Could not open temporary file $tempfile for downloading: $!/);
+ or Carp::croak(qq/Error: Could not open temporary file $tempfile for downloading: $!\n/);
binmode $fh;
$args->{data_callback} = sub { print {$fh} $_[0] };
my $response = $self->request('GET', $url, $args);
close $fh
- or Carp::croak(qq/Error: Could not close temporary file $tempfile: $!/);
+ or Carp::croak(qq/Error: Could not close temporary file $tempfile: $!\n/);
if ( $response->{success} ) {
rename $tempfile, $file
- or Carp::croak "Error replacing $file with $tempfile: $!\n";
+ or Carp::croak(qq/Error replacing $file with $tempfile: $!\n/);
my $lm = $response->{headers}{'last-modified'};
if ( $lm and my $mtime = $self->_parse_http_date($lm) ) {
utime $mtime, $mtime, $file;
@@ -86,7 +86,7 @@ my %idempotent = map { $_ => 1 } qw/GET HEAD PUT DELETE OPTIONS TRACE/;
sub request {
my ($self, $method, $url, $args) = @_;
@_ == 3 || (@_ == 4 && ref $args eq 'HASH')
- or Carp::croak(q/Usage: $http->request(METHOD, URL, [HASHREF])/);
+ or Carp::croak(q/Usage: $http->request(METHOD, URL, [HASHREF])/ . "\n");
$args ||= {}; # we keep some state in this during _request
# RFC 2616 Section 8.1.4 mandates a single retry on broken socket
@@ -134,7 +134,7 @@ sub _request {
if ($self->{proxy}) {
$request->{uri} = "$scheme://$request->{host_port}$path_query";
- croak(qq/HTTPS via proxy is not supported/)
+ die(qq/HTTPS via proxy is not supported\n/)
if $request->{scheme} eq 'https';
$handle->connect(($self->_split_url($self->{proxy}))[0..2]);
}
@@ -192,7 +192,7 @@ sub _prepare_headers_and_cb {
my $content = $args->{content};
if ( $] ge '5.008' ) {
utf8::downgrade($content, 1)
- or Carp::croak(q/Wide character in request message body/);
+ or die(qq/Wide character in request message body\n/);
}
$request->{headers}{'content-length'} = length $content
unless $request->{headers}{'content-length'}
@@ -246,7 +246,7 @@ sub _split_url {
# URI regex adapted from the URI module
my ($scheme, $authority, $path_query) = $url =~ m<\A([^:/?#]+)://([^/?#]*)([^#]*)>
- or Carp::croak(qq/Cannot parse URL: '$url'/);
+ or die(qq/Cannot parse URL: '$url'\n/);
$scheme = lc $scheme;
$path_query = "/$path_query" unless $path_query =~ m<\A/>;
@@ -298,7 +298,6 @@ package
use strict;
use warnings;
-use Carp qw[croak];
use Errno qw[EINTR EPIPE];
use IO::Socket qw[SOCK_STREAM];
@@ -333,17 +332,17 @@ my $ssl_verify_args = {
};
sub connect {
- @_ == 4 || croak(q/Usage: $handle->connect(scheme, host, port)/);
+ @_ == 4 || die(q/Usage: $handle->connect(scheme, host, port)/ . "\n");
my ($self, $scheme, $host, $port) = @_;
if ( $scheme eq 'https' ) {
eval "require IO::Socket::SSL"
unless exists $INC{'IO/Socket/SSL.pm'};
- croak(qq/IO::Socket::SSL must be installed for https support\n/)
+ die(qq/IO::Socket::SSL must be installed for https support\n/)
unless $INC{'IO/Socket/SSL.pm'};
}
elsif ( $scheme ne 'http' ) {
- croak(qq/Unsupported URL scheme '$scheme'/);
+ die(qq/Unsupported URL scheme '$scheme'\n/);
}
$self->{fh} = 'IO::Socket::INET'->new(
@@ -352,10 +351,10 @@ sub connect {
Proto => 'tcp',
Type => SOCK_STREAM,
Timeout => $self->{timeout}
- ) or croak(qq/Could not connect to '$host:$port': $@/);
+ ) or die(qq/Could not connect to '$host:$port': $@\n/);
binmode($self->{fh})
- or croak(qq/Could not binmode() socket: '$!'/);
+ or die(qq/Could not binmode() socket: '$!'\n/);
if ( $scheme eq 'https') {
IO::Socket::SSL->start_SSL($self->{fh});
@@ -372,19 +371,19 @@ sub connect {
}
sub close {
- @_ == 1 || croak(q/Usage: $handle->close()/);
+ @_ == 1 || die(q/Usage: $handle->close()/ . "\n");
my ($self) = @_;
CORE::close($self->{fh})
- or croak(qq/Could not close socket: '$!'/);
+ or die(qq/Could not close socket: '$!'\n/);
}
sub write {
- @_ == 2 || croak(q/Usage: $handle->write(buf)/);
+ @_ == 2 || die(q/Usage: $handle->write(buf)/ . "\n");
my ($self, $buf) = @_;
if ( $] ge '5.008' ) {
utf8::downgrade($buf, 1)
- or croak(q/Wide character in write()/);
+ or die(qq/Wide character in write()\n/);
}
my $len = length $buf;
@@ -394,7 +393,7 @@ sub write {
while () {
$self->can_write
- or croak(q/Timed out while waiting for socket to become ready for writing/);
+ or die(qq/Timed out while waiting for socket to become ready for writing\n/);
my $r = syswrite($self->{fh}, $buf, $len, $off);
if (defined $r) {
$len -= $r;
@@ -402,17 +401,17 @@ sub write {
last unless $len > 0;
}
elsif ($! == EPIPE) {
- croak(qq/Socket closed by remote server: $!/);
+ die(qq/Socket closed by remote server: $!\n/);
}
elsif ($! != EINTR) {
- croak(qq/Could not write to socket: '$!'/);
+ die(qq/Could not write to socket: '$!'\n/);
}
}
return $off;
}
sub read {
- @_ == 2 || @_ == 3 || croak(q/Usage: $handle->read(len [, allow_partial])/);
+ @_ == 2 || @_ == 3 || die(q/Usage: $handle->read(len [, allow_partial])/ . "\n");
my ($self, $len, $allow_partial) = @_;
my $buf = '';
@@ -426,24 +425,24 @@ sub read {
while ($len > 0) {
$self->can_read
- or croak(q/Timed out while waiting for socket to become ready for reading/);
+ or die(q/Timed out while waiting for socket to become ready for reading/ . "\n");
my $r = sysread($self->{fh}, $buf, $len, length $buf);
if (defined $r) {
last unless $r;
$len -= $r;
}
elsif ($! != EINTR) {
- croak(qq/Could not read from socket: '$!'/);
+ die(qq/Could not read from socket: '$!'\n/);
}
}
if ($len && !$allow_partial) {
- croak(q/Unexpected end of stream/);
+ die(qq/Unexpected end of stream\n/);
}
return $buf;
}
sub readline {
- @_ == 1 || croak(q/Usage: $handle->readline()/);
+ @_ == 1 || die(q/Usage: $handle->readline()/ . "\n");
my ($self) = @_;
while () {
@@ -451,23 +450,23 @@ sub readline {
return $1;
}
if (length $self->{rbuf} >= $self->{max_line_size}) {
- croak(qq/Line size exceeds the maximum allowed size of $self->{max_line_size}/);
+ die(qq/Line size exceeds the maximum allowed size of $self->{max_line_size}\n/);
}
$self->can_read
- or croak(q/Timed out while waiting for socket to become ready for reading/);
+ or die(qq/Timed out while waiting for socket to become ready for reading\n/);
my $r = sysread($self->{fh}, $self->{rbuf}, BUFSIZE, length $self->{rbuf});
if (defined $r) {
last unless $r;
}
elsif ($! != EINTR) {
- croak(qq/Could not read from socket: '$!'/);
+ die(qq/Could not read from socket: '$!'\n/);
}
}
- croak(q/Unexpected end of stream while looking for line/);
+ die(qq/Unexpected end of stream while looking for line\n/);
}
sub read_header_lines {
- @_ == 1 || @_ == 2 || croak(q/Usage: $handle->read_header_lines([headers])/);
+ @_ == 1 || @_ == 2 || die(q/Usage: $handle->read_header_lines([headers])/ . "\n");
my ($self, $headers) = @_;
$headers ||= {};
my $lines = 0;
@@ -477,7 +476,7 @@ sub read_header_lines {
my $line = $self->readline;
if (++$lines >= $self->{max_header_lines}) {
- croak(qq/Header lines exceeds maximum number allowed of $self->{max_header_lines}/);
+ die(qq/Header lines exceeds maximum number allowed of $self->{max_header_lines}\n/);
}
elsif ($line =~ /\A ([^\x00-\x1F\x7F:]+) : [\x09\x20]* ([^\x0D\x0A]*)/x) {
my ($field_name) = lc $1;
@@ -494,7 +493,7 @@ sub read_header_lines {
}
elsif ($line =~ /\A [\x09\x20]+ ([^\x0D\x0A]*)/x) {
$val
- or croak(q/Unexpected header continuation line/);
+ or die(qq/Unexpected header continuation line\n/);
next unless length $1;
$$val .= ' ' if length $$val;
$$val .= $1;
@@ -503,14 +502,14 @@ sub read_header_lines {
last;
}
else {
- croak(q/Malformed header line: / . $Printable->($line));
+ die(q/Malformed header line: / . $Printable->($line) . "\n");
}
}
return $headers;
}
sub write_request {
- @_ == 2 || croak(q/Usage: $handle->write_request(request)/);
+ @_ == 2 || die(q/Usage: $handle->write_request(request)/ . "\n");
my($self, $request) = @_;
$self->write_request_header(@{$request}{qw/method uri headers/});
$self->write_body($request) if $request->{cb};
@@ -526,7 +525,7 @@ my %HeaderCase = (
);
sub write_header_lines {
- (@_ == 2 && ref $_[1] eq 'HASH') || croak(q/Usage: $handle->write_header_lines(headers)/);
+ (@_ == 2 && ref $_[1] eq 'HASH') || die(q/Usage: $handle->write_header_lines(headers)/ . "\n");
my($self, $headers) = @_;
my $buf = '';
@@ -537,13 +536,13 @@ sub write_header_lines {
}
else {
$field_name =~ /\A $Token+ \z/xo
- or croak(q/Invalid HTTP header field name: / . $Printable->($field_name));
+ or die(q/Invalid HTTP header field name: / . $Printable->($field_name) . "\n");
$field_name =~ s/\b(\w)/\u$1/g;
$HeaderCase{lc $field_name} = $field_name;
}
for (ref $v eq 'ARRAY' ? @$v : $v) {
/[^\x0D\x0A]/
- or croak(qq/Invalid HTTP header field value ($field_name): / . $Printable->($_));
+ or die(qq/Invalid HTTP header field value ($field_name): / . $Printable->($_). "\n");
$buf .= "$field_name: $_\x0D\x0A";
}
}
@@ -552,7 +551,7 @@ sub write_header_lines {
}
sub read_body {
- @_ == 3 || croak(q/Usage: $handle->read_body(callback, response)/);
+ @_ == 3 || die(q/Usage: $handle->read_body(callback, response)/ . "\n");
my ($self, $cb, $response) = @_;
my $te = $response->{headers}{'transfer-encoding'} || '';
if ( grep { /chunked/i } ( ref $te eq 'ARRAY' ? @$te : $te ) ) {
@@ -565,7 +564,7 @@ sub read_body {
}
sub write_body {
- @_ == 2 || croak(q/Usage: $handle->write_body(request)/);
+ @_ == 2 || die(q/Usage: $handle->write_body(request)/ . "\n");
my ($self, $request) = @_;
if ($request->{headers}{'content-length'}) {
return $self->write_content_body($request);
@@ -576,7 +575,7 @@ sub write_body {
}
sub read_content_body {
- @_ == 3 || @_ == 4 || croak(q/Usage: $handle->read_content_body(callback, response, [read_length])/);
+ @_ == 3 || @_ == 4 || die(q/Usage: $handle->read_content_body(callback, response, [read_length])/ . "\n");
my ($self, $cb, $response, $content_length) = @_;
$content_length ||= $response->{headers}{'content-length'};
@@ -597,7 +596,7 @@ sub read_content_body {
}
sub write_content_body {
- @_ == 2 || croak(q/Usage: $handle->write_content_body(request)/);
+ @_ == 2 || die(q/Usage: $handle->write_content_body(request)/ . "\n");
my ($self, $request) = @_;
my ($len, $content_length) = (0, $request->{headers}{'content-length'});
@@ -609,27 +608,27 @@ sub write_content_body {
if ( $] ge '5.008' ) {
utf8::downgrade($data, 1)
- or croak(q/Wide character in write_content()/);
+ or die(qq/Wide character in write_content()\n/);
}
$len += $self->write($data);
}
$len == $content_length
- or croak(qq/Content-Length missmatch (got: $len expected: $content_length)/);
+ or die(qq/Content-Length missmatch (got: $len expected: $content_length)\n/);
return $len;
}
sub read_chunked_body {
- @_ == 3 || croak(q/Usage: $handle->read_chunked_body(callback, $response)/);
+ @_ == 3 || die(q/Usage: $handle->read_chunked_body(callback, $response)/ . "\n");
my ($self, $cb, $response) = @_;
while () {
my $head = $self->readline;
$head =~ /\A ([A-Fa-f0-9]+)/x
- or croak(q/Malformed chunk head: / . $Printable->($head));
+ or die(q/Malformed chunk head: / . $Printable->($head) . "\n");
my $len = hex($1)
or last;
@@ -637,14 +636,14 @@ sub read_chunked_body {
$self->read_content_body($cb, $response, $len);
$self->read(2) eq "\x0D\x0A"
- or croak(q/Malformed chunk: missing CRLF after chunk data/);
+ or die(qq/Malformed chunk: missing CRLF after chunk data\n/);
}
$self->read_header_lines($response->{headers});
return;
}
sub write_chunked_body {
- @_ == 2 || croak(q/Usage: $handle->write_chunked_body(request)/);
+ @_ == 2 || die(q/Usage: $handle->write_chunked_body(request)/ . "\n");
my ($self, $request) = @_;
my $len = 0;
@@ -656,7 +655,7 @@ sub write_chunked_body {
if ( $] ge '5.008' ) {
utf8::downgrade($data, 1)
- or croak(q/Wide character in write_chunked_body()/);
+ or die(qq/Wide character in write_chunked_body()\n/);
}
$len += length $data;
@@ -675,17 +674,17 @@ sub write_chunked_body {
}
sub read_response_header {
- @_ == 1 || croak(q/Usage: $handle->read_response_header()/);
+ @_ == 1 || die(q/Usage: $handle->read_response_header()/ . "\n");
my ($self) = @_;
my $line = $self->readline;
$line =~ /\A (HTTP\/(0*\d+\.0*\d+)) [\x09\x20]+ ([0-9]{3}) [\x09\x20]+ ([^\x0D\x0A]*) \x0D?\x0A/x
- or croak(q/Malformed Status-Line: / . $Printable->($line));
+ or die(q/Malformed Status-Line: / . $Printable->($line). "\n");
my ($protocol, $version, $status, $reason) = ($1, $2, $3, $4);
- croak (qq/Unsupported HTTP protocol: $protocol/)
+ die (qq/Unsupported HTTP protocol: $protocol\n/)
unless $version =~ /0*1\.0*[01]/;
return {
@@ -697,7 +696,7 @@ sub read_response_header {
}
sub write_request_header {
- @_ == 4 || croak(q/Usage: $handle->write_request_header(method, request_uri, headers)/);
+ @_ == 4 || die(q/Usage: $handle->write_request_header(method, request_uri, headers)/ . "\n");
my ($self, $method, $request_uri, $headers) = @_;
return $self->write("$method $request_uri HTTP/1.1\x0D\x0A")
@@ -711,7 +710,7 @@ sub _do_timeout {
my $fd = fileno $self->{fh};
defined $fd && $fd >= 0
- or croak(q/select(2): 'Bad file descriptor'/);
+ or die(qq/select(2): 'Bad file descriptor'\n/);
my $initial = time;
my $pending = $timeout;
@@ -725,7 +724,7 @@ sub _do_timeout {
: select(undef, $fdset, undef, $pending) ;
if ($nfound == -1) {
$! == EINTR
- or croak(qq/select(2): '$!'/);
+ or die(qq/select(2): '$!'\n/);
redo if !$timeout || ($pending = $timeout - (time - $initial)) > 0;
$nfound = 0;
}
@@ -736,19 +735,21 @@ sub _do_timeout {
}
sub can_read {
- @_ == 1 || @_ == 2 || croak(q/Usage: $handle->can_read([timeout])/);
+ @_ == 1 || @_ == 2 || die(q/Usage: $handle->can_read([timeout])/ . "\n");
my $self = shift;
return $self->_do_timeout('read', @_)
}
sub can_write {
- @_ == 1 || @_ == 2 || croak(q/Usage: $handle->can_write([timeout])/);
+ @_ == 1 || @_ == 2 || die(q/Usage: $handle->can_write([timeout])/ . "\n");
my $self = shift;
return $self->_do_timeout('write', @_)
}
1;
+# ABSTRACT: A small, simple, correct HTTP/1.1 client
+
__END__
@@ -760,7 +761,7 @@ HTTP::Tiny - A small, simple, correct HTTP/1.1 client
=head1 VERSION
-version 0.012
+version 0.013
=head1 SYNOPSIS
@@ -828,7 +829,7 @@ responses larger than this will die with an error message
proxy
-URL of a proxy server to use.
+URL of a proxy server to use (default is C<$ENV{http_proxy}> if set)
=item *
@@ -1027,7 +1028,9 @@ inappropriately re-transmitted.
=item *
-Proxy environment variables are not supported.
+Only the C<http_proxy> environment variable is supported in the format
+C<http://HOST:PORT/>. If a C<proxy> argument is passed to C<new> (including
+undef), then the C<http_proxy> environment variable is ignored.
=item *
@@ -1069,9 +1072,9 @@ progress on the request by the system.
This is open source software. The code repository is available for
public review and contribution under the terms of the license.
-L<http://github.com/dagolden/p5-http-tiny/tree>
+L<http://github.com/dagolden/p5-http-tiny>
- git clone git://github.com/dagolden/p5-http-tiny.git
+ git clone http://github.com/dagolden/p5-http-tiny
=head1 AUTHORS
diff --git a/cpan/HTTP-Tiny/t/00-compile.t b/cpan/HTTP-Tiny/t/00-compile.t
index 277185d8e5..6ce3690f2f 100644
--- a/cpan/HTTP-Tiny/t/00-compile.t
+++ b/cpan/HTTP-Tiny/t/00-compile.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
@@ -32,7 +24,18 @@ find(
'lib',
);
-my @scripts = glob "bin/*";
+my @scripts;
+if ( -d 'bin' ) {
+ find(
+ sub {
+ return unless -f;
+ my $found = $File::Find::name;
+ # nothing to skip
+ push @scripts, $found;
+ },
+ 'bin',
+ );
+}
my $plan = scalar(@modules) + scalar(@scripts);
$plan ? (plan tests => $plan) : (plan skip_all => "no tests to run");
diff --git a/cpan/HTTP-Tiny/t/000_load.t b/cpan/HTTP-Tiny/t/000_load.t
index 59c4aa6cab..052298ac73 100644
--- a/cpan/HTTP-Tiny/t/000_load.t
+++ b/cpan/HTTP-Tiny/t/000_load.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
diff --git a/cpan/HTTP-Tiny/t/001_api.t b/cpan/HTTP-Tiny/t/001_api.t
index 12050a07a0..85dc9370d8 100644
--- a/cpan/HTTP-Tiny/t/001_api.t
+++ b/cpan/HTTP-Tiny/t/001_api.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
diff --git a/cpan/HTTP-Tiny/t/002_croakage.t b/cpan/HTTP-Tiny/t/002_croakage.t
index 317f0a7cb4..a243ebce5a 100644
--- a/cpan/HTTP-Tiny/t/002_croakage.t
+++ b/cpan/HTTP-Tiny/t/002_croakage.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
diff --git a/cpan/HTTP-Tiny/t/010_url.t b/cpan/HTTP-Tiny/t/010_url.t
index 58ba1179ab..ed63396014 100644
--- a/cpan/HTTP-Tiny/t/010_url.t
+++ b/cpan/HTTP-Tiny/t/010_url.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
diff --git a/cpan/HTTP-Tiny/t/020_headers.t b/cpan/HTTP-Tiny/t/020_headers.t
index 3a6fc63b8d..970faa6d7b 100644
--- a/cpan/HTTP-Tiny/t/020_headers.t
+++ b/cpan/HTTP-Tiny/t/020_headers.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
diff --git a/cpan/HTTP-Tiny/t/030_response.t b/cpan/HTTP-Tiny/t/030_response.t
index fbeea58133..fc72a3afc0 100644
--- a/cpan/HTTP-Tiny/t/030_response.t
+++ b/cpan/HTTP-Tiny/t/030_response.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
diff --git a/cpan/HTTP-Tiny/t/040_content.t b/cpan/HTTP-Tiny/t/040_content.t
index e69bbedc4b..64e432e9e1 100644
--- a/cpan/HTTP-Tiny/t/040_content.t
+++ b/cpan/HTTP-Tiny/t/040_content.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
diff --git a/cpan/HTTP-Tiny/t/050_chunked_body.t b/cpan/HTTP-Tiny/t/050_chunked_body.t
index 16c9cf7a7c..b555b00a72 100644
--- a/cpan/HTTP-Tiny/t/050_chunked_body.t
+++ b/cpan/HTTP-Tiny/t/050_chunked_body.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
diff --git a/cpan/HTTP-Tiny/t/060_http_date.t b/cpan/HTTP-Tiny/t/060_http_date.t
index bd7077a05d..367c0783e9 100644
--- a/cpan/HTTP-Tiny/t/060_http_date.t
+++ b/cpan/HTTP-Tiny/t/060_http_date.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
diff --git a/cpan/HTTP-Tiny/t/100_get.t b/cpan/HTTP-Tiny/t/100_get.t
index 1d9dd91f12..35251e0f12 100644
--- a/cpan/HTTP-Tiny/t/100_get.t
+++ b/cpan/HTTP-Tiny/t/100_get.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
diff --git a/cpan/HTTP-Tiny/t/110_mirror.t b/cpan/HTTP-Tiny/t/110_mirror.t
index 7f10ff1dbf..7a54bb7856 100644
--- a/cpan/HTTP-Tiny/t/110_mirror.t
+++ b/cpan/HTTP-Tiny/t/110_mirror.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
diff --git a/cpan/HTTP-Tiny/t/120_put.t b/cpan/HTTP-Tiny/t/120_put.t
index 07fa27dc5c..e0c98d7854 100644
--- a/cpan/HTTP-Tiny/t/120_put.t
+++ b/cpan/HTTP-Tiny/t/120_put.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
diff --git a/cpan/HTTP-Tiny/t/130_redirect.t b/cpan/HTTP-Tiny/t/130_redirect.t
index 9848321043..68d92557d7 100644
--- a/cpan/HTTP-Tiny/t/130_redirect.t
+++ b/cpan/HTTP-Tiny/t/130_redirect.t
@@ -1,12 +1,4 @@
#!perl
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
use strict;
use warnings;
diff --git a/cpan/HTTP-Tiny/t/140_proxy.t b/cpan/HTTP-Tiny/t/140_proxy.t
new file mode 100644
index 0000000000..295d7cf46f
--- /dev/null
+++ b/cpan/HTTP-Tiny/t/140_proxy.t
@@ -0,0 +1,35 @@
+#!perl
+
+use strict;
+use warnings;
+
+use File::Basename;
+use Test::More 0.88;
+
+use HTTP::Tiny;
+
+# Require a true value
+for my $proxy (undef, "", 0){
+ local $ENV{http_proxy} = $proxy;
+ my $c = HTTP::Tiny->new();
+ ok(!defined $c->proxy);
+}
+
+# trailing / is optional
+for my $proxy ("http://localhost:8080/", "http://localhost:8080"){
+ local $ENV{http_proxy} = $proxy;
+ my $c = HTTP::Tiny->new();
+ is($c->proxy, $proxy);
+}
+
+# http_proxy must be http://<host>:<port> format
+{
+ local $ENV{http_proxy} = "localhost:8080";
+ eval {
+ my $c = HTTP::Tiny->new();
+ };
+ like($@, qr{Environment 'http_proxy' must be in format http://<host>:<port>/});
+}
+
+
+done_testing(); \ No newline at end of file
diff --git a/cpan/HTTP-Tiny/t/Util.pm b/cpan/HTTP-Tiny/t/Util.pm
index d049487451..72b0770449 100644
--- a/cpan/HTTP-Tiny/t/Util.pm
+++ b/cpan/HTTP-Tiny/t/Util.pm
@@ -1,11 +1,3 @@
-#
-# This file is part of HTTP-Tiny
-#
-# This software is copyright (c) 2011 by Christian Hansen.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
package t::Util;
use strict;
@@ -172,6 +164,8 @@ sub sort_headers {
$self->{fh} = shift @res_fh;
};
*HTTP::Tiny::Handle::close = sub { 1 }; # don't close our temps
+
+ delete $ENV{http_proxy}; # don't try to proxy in mock-mode
}
}