Permalink
Browse files

Item14545: Implement NoProxy

  • Loading branch information...
MichaelDaum committed Dec 1, 2017
1 parent b778ff1 commit 215bcecef20df0657a04950f19509b8074595499
Showing with 10 additions and 0 deletions.
  1. +4 −0 core/lib/Foswiki.spec
  2. +6 −0 core/lib/Foswiki/Net.pm
@@ -1084,6 +1084,10 @@ $Foswiki::cfg{AccessibleHeaders} = ['Accept-Language', 'User-Agent'];
# http://username:password@proxy.your.company:8080.
$Foswiki::cfg{PROXY}{HOST} = undef;
# **STRING 50 LABEL="No Proxy" CHECK="undefok emptyok"**
# List of domains that are accessed directly instead of going by the proxy.
$Foswiki::cfg{PROXY}{NoProxy} = '';
# **BOOLEAN LABEL="Client IP" **
# Foswiki normally uses the REMOTE_ADDRESS as the client IP. If Foswiki is behind
# a proxy, Foswiki will see the proxy's address as the Client IP. Enable this switch if you
@@ -116,6 +116,11 @@ sub getExternalResource {
my $uri = URI::URL->new($url);
my $proxyHost = $this->{PROXYHOST} || $Foswiki::cfg{PROXY}{HOST};
my $puri = $proxyHost ? URI::URL->new($proxyHost) : undef;
my @noProxy =
( $puri && $Foswiki::cfg{PROXY}{NoProxy} )
? split( /\s*,\s*/, $Foswiki::cfg{PROXY}{NoProxy} )
: undef;
my $request;
require HTTP::Request;
@@ -138,6 +143,7 @@ sub getExternalResource {
if ( $uri->can("userinfo") && defined $uri->userinfo() );
my $ua = new Foswiki::Net::UserCredAgent( $user, $pass );
$ua->proxy( [ 'http', 'https' ], $puri->as_string() ) if $puri;
$ua->no_proxy(@noProxy) if @noProxy;
my $response = $ua->request($request);
return $response;
}

0 comments on commit 215bcec

Please sign in to comment.