Permalink
Browse files

Make it possible to unset the proxy settings again

In 5.821 we started to croak if bad proxy URLs was passed in, but
this check should not trigger when we try to unset the proxy URL.

Some also seems to set $ENV{http_proxy} to the empty string.
  • Loading branch information...
1 parent 8ffaf80 commit acfeaa492ec376b24570b559af6073c59f2db38a @gisle committed Dec 2, 2008
Showing with 8 additions and 3 deletions.
  1. +4 −2 lib/LWP/UserAgent.pm
  2. +4 −1 t/base/ua.t
View
@@ -921,8 +921,10 @@ sub proxy
my $old = $self->{'proxy'}{$key};
if (@_) {
my $url = shift;
- Carp::croak("Proxy must be specified as absolute URI; '$url' is not") unless $url =~ /^$URI::scheme_re:/;
- Carp::croak("Bad http proxy specification '$url'") if $url =~ /^https?:/ && $url !~ m,^https?://\w,;
+ if (defined($url) && length($url)) {
+ Carp::croak("Proxy must be specified as absolute URI; '$url' is not") unless $url =~ /^$URI::scheme_re:/;
+ Carp::croak("Bad http proxy specification '$url'") if $url =~ /^https?:/ && $url !~ m,^https?://\w,;
+ }
$self->{proxy}{$key} = $url;
$self->set_my_handler("request_preprepare", \&_need_proxy)
}
View
@@ -3,7 +3,7 @@
use strict;
use Test;
-plan tests => 10;
+plan tests => 12;
use LWP::UserAgent;
@@ -40,3 +40,6 @@ X: y
EOT
ok(ref($clone->{proxy}), 'HASH');
+
+ok($ua->proxy(http => undef), "loopback:");
+ok($ua->proxy('http'), undef);

0 comments on commit acfeaa4

Please sign in to comment.