1#!perl 2 3use strict; 4use warnings; 5 6use File::Basename; 7use Test::More 0.88; 8 9use HTTP::Tiny; 10 11# Require a true value 12for my $proxy (undef, "", 0){ 13 local $ENV{http_proxy} = $proxy; 14 my $c = HTTP::Tiny->new(); 15 ok(!defined $c->http_proxy); 16} 17 18# trailing / is optional 19for my $proxy ("http://localhost:8080/", "http://localhost:8080"){ 20 local $ENV{http_proxy} = $proxy; 21 my $c = HTTP::Tiny->new(); 22 is($c->http_proxy, $proxy); 23} 24 25# http_proxy must be http://<host>:<port> format 26{ 27 local $ENV{http_proxy} = "localhost:8080"; 28 eval { 29 my $c = HTTP::Tiny->new(); 30 }; 31 like($@, qr{http_proxy URL must be in format http\[s\]://\[auth\@\]<host>:<port>/}); 32} 33 34 35done_testing(); 36