Ryan Eatmon > HTTP-ProxyAutoConfig-0.1 > HTTP::ProxyAutoConfig

Download:
HTTP-ProxyAutoConfig-0.1.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.1   Source  

NAME ^

HTTP::ProxyAutoConfig - provides a unifed way to get the proxy information

SYNOPSIS ^

HTTP::ProxyAutoConfig is a module that allows perl scripts that need access to proxy servers to utilize the standard proxy settings provided by an IT department.

DESCRIPTION ^

This module provides a consistent method for finding the proxy server needed to talk to for a given URL. It can handle parsing the http_proxy, https_proxy, ftp_proxy, and http_auto_proxy variables to determine what it is you want it to do. If you set the http_auto_proxy variable it overrides the others and fetches the PAC file from there and uses those settings.

Access to the proxy information is provided in a single function call to FindProxyForURL(url,host). A string is returned that tells you what to do, either "DIRECT", "PROXY host:port", or "SOCKS host:port".

The Proxy Auto Config format and rules are defined at Netscape:

http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html

The file basically works by defining a JavaScript function called FindProxyForURL. This module fetches that file and converts the JavaScript function into a Perl function and then defines the Perl function with that converted data.

METHODS ^

  new(url) - creates the FindProxyForURL function and the object.
             The url argument is optional, and points to the auto-proxy
             file provided on your network.  If you do not specify a
             url, then it will check the http_auto_proxy variable,
             followed by the http_proxy, https_proxy, and ftp_proxy
             variables.

  my $pac = new HTTP::ProxyAutoConfig("http://foo.bar/auto-proxy.pac");
  my $pac = new HTTP::ProxyAutoConfig();

  FindProxyForURL(url,host) - takes the url, and the host (minus
                              port) from the URL, and determines the
                              action you should take to contact that
                              host.  It returns one of three things:

                                DIRECT           - connect directly to them
                                PROXY host:port  - connect via the proxy
                                SOCKS host:port  - connect via SOCKS

  FindProxy(url) - calls the FindProxyForURL function and passes it the
                   correct options.  This is just a wrapper.

  Reload() - allows you to fetch the PAC again and regenerate the
             FindProxyForURL function based on anything you might
             have changed in the environment.

AUTHOR ^

By Ryan Eatmon in May of 2001

COPYRIGHT ^

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: