NAME

HTTP::Proxy - A pure Perl HTTP proxy

SYNOPSIS

use HTTP::Proxy;

# initialisation
my $proxy = HTTP::Proxy->new( port => 3128 );

# alternate initialisation
my $proxy = HTTP::Proxy->new;
$proxy->port( 3128 ); # the classical accessors are here!

# you can also use your own UserAgent
my $agent = LWP::RobotUA->new;
$proxy->agent( $agent );

# this is a MainLoop-like method
$proxy->start;

DESCRIPTION

This module implements a HTTP Proxy, using a HTTP::Daemon to accept client connections, and a LWP::UserAgent to ask for the requested pages.

METHODS

Constructor

Accessors

The HTTP::Proxy has several accessors. They are all AUTOLOADed.

Called with arguments, the accessor returns the current value. Called with a single argument, it set the current value and returns the previous one, in case you want to keep it.

If you call a read-only accessor with a parameter, this parameter will be ignored.

The defined accessors are (in alphabetical order):

agent

The LWP::UserAgent object used internally to connect to remote sites.

daemon

The HTTP::Daemon object used to accept incoming connections. (You usually never need this.)

host

The proxy HTTP::Daemon host (default: 'localhost').

logfh

A filehandle to a logfile (default: *STDERR).

maxchild

The maximum number of child process the HTTP::Proxy object will spawn to handle client requests (default: 16).

maxconn

The maximum number of connections the proxy will accept before returning from start(). 0 (the default) means never stop accepting connections.

port

The proxy HTTP::Daemon port (default: 8080).

conn (read-only)

The number of connections processed by this HTTP::Proxy instance.

verbose

Be verbose in the logs (default: 0).

The start() method

This method works like Tk's MainLoop: you hand over control to the HTTP::Proxy object you created and configured.

If maxconn is not zero, start() will return after accepting at most that many connections.

Other methods

Callbacks

You can alter the way the default HTTP::Proxy works by pluging callbacks at different stages of the request/response handling.

(TO BE IMPLEMENTED)

BUGS

Some connections to the client are never closed. (HTTP::Proxy should handle the client and the server connection separately.)

TODO

* Provide an interface for logging.

* Remove forking, so that all data is in one place

* Provide control over the proxy through special URLs

AUTHOR

Philippe "BooK" Bruhat, <book@cpan.org>.