home *** CD-ROM | disk | FTP | other *** search
/ CLIX - Fazer Clix Custa Nix / CLIX-CD.cdr / mac / lib / auto / LWP / UserAgent / _need_proxy.al next >
Text File  |  1997-12-13  |  940b  |  44 lines

  1. # NOTE: Derived from :lib:LWP:UserAgent.pm.  Changes made here will be lost.
  2. package LWP::UserAgent;
  3.  
  4. # Private method which returns the URL of the Proxy configured for this
  5. # URL, or undefined if none is configured.
  6. sub _need_proxy
  7. {
  8.     my($self, $url) = @_;
  9.  
  10.     $url = new URI::URL($url) unless ref $url;
  11.  
  12.     LWP::Debug::trace("($url)");
  13.  
  14.     # check the list of noproxies
  15.  
  16.     if (@{ $self->{'no_proxy'} }) {
  17.     my $host = $url->host;
  18.     return undef unless defined $host;
  19.     my $domain;
  20.     for $domain (@{ $self->{'no_proxy'} }) {
  21.         if ($host =~ /$domain$/) {
  22.         LWP::Debug::trace("no_proxy configured");
  23.         return undef;
  24.         }
  25.     }
  26.     }
  27.  
  28.     # Currently configured per scheme.
  29.     # Eventually want finer granularity
  30.  
  31.     my $scheme = $url->scheme;
  32.     if (exists $self->{'proxy'}{$scheme}) {
  33.  
  34.     LWP::Debug::debug('Proxied');
  35.     return new URI::URL($self->{'proxy'}{$scheme});
  36.     }
  37.  
  38.     LWP::Debug::debug('Not proxied');
  39.     undef;
  40. }
  41.  
  42. 1;
  43. 1;
  44.