Tatsuhiko Miyagawa > HTTP-ProxyPAC-0.01 > HTTP::ProxyPAC

Download:
HTTP-ProxyPAC-0.01.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.01   Source   Latest Release: HTTP-ProxyPAC-0.31

NAME ^

HTTP::ProxyPAC - parse PAC (Proxy Auto Config) files

SYNOPSIS ^

  use HTTP::ProxyPAC;

  my $pac = HTTP::ProxyPAC->new( URI->new("http://www.example.com/proxy.pac") );
  my $res = $pac->find_proxy("http://www.google.com/");

  if ($res->direct) {
      ...
  } elsif ($res->proxy) {
      $ua->proxy('http' => $res->proxy);
  }

DESCRIPTION ^

HTTP::ProxyPAC is a plugin to parse Proxy Auto Configuration file to find appropriate proxy for any URL. You can share the same proxy setup by using the same proxy.pac file as your favorite browsers like Firefox, IE or Opera.

METHODS ^

new
  HTTP::ProxyPAC->new(URI->new("http://example.com/proxy.pac"));
  HTTP::ProxyPAC->new("/path/to/proxy.pac");
  HTTP::ProxyPAC->new(\$content);
  HTTP::ProxyPAC->new($fh);

Creates new HTTP::ProxyPAC object. It accepts arguments such as URI object, path to the proxy.pac file, scalar reference to the JavaScript code, filehandle or IO::Handle object.

find_proxy
  $res = $pac->find_proxy($url);
  @res = $pac->find_proxy($url);

Wrapper method for the JavaScript FindProxyForURL function. Takes URL as string or URI object and returns HTTP::ProxyPAC::Result object.

FindProxyForURL function might return multiple candidates. In that case, find_proxy will return Result objects as arrray in an array context, and only the first result in a scalar context.

WHAT ABOUT HTTP::ProxyAutoConfig? ^

I know that there's already HTTP::ProxyAutoConfig module that exactly does the same thing, and actually this module reuses lots of PAC functions defined there (Thanks!).

The reason why I wrote this module is, Javascript2Perl converter function defined in HTTP::ProxyAutoConfig looks horrible, and actually the generated perl code doesn't compile for me. So I created yet another module of mine that uses SpiderMonkey based JavaScript binding, which might be overkill for this task, but should definitely be more robust.

AUTHOR ^

Tatsuhiko Miyagawa <miyagawa@bulknews.net>

Ryan Eatmon wrote PAC functions in Perl for HTTP::ProxyAutoConfig, where I copied all the HTTP::ProxyPac::Functions from.

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

SEE ALSO ^

HTTP::ProxyAutoConfig, JavaScript, http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html

syntax highlighting: