Skip to content

Commit ef31da4

Browse files
committed
Testing a possible fix for #337
1 parent 9ce0d30 commit ef31da4

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/Bio/Root/HTTPget.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ sub proxy {
375375
my ($protocol,$proxy,$username,$password) = @_;
376376
my $atts = ref($self) ? $self : \%attributes;
377377
$protocol ||= 'http';
378-
if (!$proxy) {
378+
if (!$proxy && !defined($atts->{'_proxy'}->{$protocol})) {
379379
if (defined $ENV{http_proxy}) {
380380
$proxy = $ENV{http_proxy};
381381
if ($proxy =~ /\@/) {

t/Root/HTTPget.t

+8-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ isa_ok($fh, 'IO::Socket::INET');
4242

4343
undef($fh);
4444

45-
is ($obj->proxy(), undef);
45+
# Note: this needs to handle cases when http_proxy is set in the environment
46+
47+
is ($obj->proxy(), $ENV{http_proxy});
4648
is_deeply([$obj->authentication], []);
4749
$obj->proxy('http', $TEST_PROXY);
4850
$obj->authentication(@TEST_AUTHENTICATION);
@@ -58,7 +60,7 @@ isa_ok($fh, 'IO::Socket::INET');
5860

5961
undef($fh);
6062

61-
is (Bio::Root::HTTPget->proxy(), undef);
63+
is (Bio::Root::HTTPget->proxy(), $ENV{http_proxy});
6264
is_deeply([Bio::Root::HTTPget->authentication], []);
6365
Bio::Root::HTTPget->proxy('http', $TEST_PROXY);
6466
Bio::Root::HTTPget->authentication(@TEST_AUTHENTICATION);
@@ -78,7 +80,9 @@ undef($fh);
7880
Bio::Root::HTTPget->authentication(undef, undef);
7981

8082
my $old = Bio::Root::HTTPget->clear_proxy('http');
81-
is (Bio::Root::HTTPget::proxy(), undef);
83+
84+
# Note this falls back to whatever $ENV{http_proxy} is set to
85+
is (Bio::Root::HTTPget::proxy(), $ENV{http_proxy});
8286
is ($old, $TEST_PROXY);
8387

8488
is_deeply([Bio::Root::HTTPget->authentication], [undef, undef]);
@@ -94,7 +98,7 @@ my $newobj = Bio::Root::HTTPget->new();
9498

9599
ok defined($newobj) && $obj->isa('Bio::Root::Root');
96100

97-
is ($newobj->proxy(), undef);
101+
is ($newobj->proxy(), $ENV{http_proxy});
98102
is_deeply([$newobj->authentication], []);
99103
$newobj->proxy('http', $TEST_PROXY);
100104
$newobj->authentication(@TEST_AUTHENTICATION);

0 commit comments

Comments
 (0)