HTTP-Proxy
view release on metacpan or search on metacpan
lib/HTTP/Proxy.pm view on Meta::CPAN
=item port
The proxy L<HTTP::Daemon> port (default: 8080).
=item request
The request originally received by the proxy from the user-agent, which
will be modified by the request filters.
=item response
The response received from the origin server by the proxy. It is
normally C<undef> until the proxy actually receives the beginning
of a response from the origin server.
If one of the request filters sets this attribute, it "short-circuits"
the request/response scheme, and the proxy will return this response
(which is NOT filtered through the response filter stacks) instead of
the expected origin server response. This is useful for caching (though
Squid does it much better) and proxy authentication, for example.
=item stash
The stash is a hash where filters can store data to share between them.
The stash() method can be used to set the whole hash (with a HASH reference).
To access individual keys simply do:
$proxy->stash( 'bloop' );
To set it, type:
$proxy->stash( bloop => 'owww' );
It's also possibly to get a reference to the stash:
my $s = $filter->proxy->stash();
$s->{bang} = 'bam';
# $proxy->stash( 'bang' ) will now return 'bam'
B<Warning:> since the proxy forks for each TCP connection, the data is
only shared between filters in the same child process.
=item timeout
The timeout used by the internal L<LWP::UserAgent> (default: 60).
=item url (read-only)
The url where the proxy can be reached.
=item via
The content of the Via: header. Setting it to an empty string will
prevent its addition. (default: C<$hostname (HTTP::Proxy/$VERSION)>)
=item x_forwarded_for
If set to a true value, the proxy will send the C<X-Forwarded-For:> header.
(default: true)
=back
=head2 Connection handling methods
=over 4
=item start()
This method works like Tk's C<MainLoop>: you hand over control to the
L<HTTP::Proxy> object you created and configured.
If C<maxconn> is not zero, C<start()> will return after accepting
at most that many connections. It will return the total number of
connexions.
=item serve_connections()
This is the internal method used to handle each new TCP connection
to the proxy.
=back
=head2 Other methods
=over 4
=item log( $level, $prefix, $message )
Adds C<$message> at the end of C<logfh>, if $level matches C<logmask>.
The C<log()> method also prints a timestamp.
The output looks like:
[Thu Dec 5 12:30:12 2002] ($$) $prefix: $message
where C<$$> is the current process's id.
If C<$message> is a multiline string, several log lines will be output,
each line starting with C<$prefix>.
=item is_protocol_supported( $scheme )
Returns a boolean indicating if $scheme is supported by the proxy.
This method is only used internally.
It is essential to allow L<HTTP::Proxy> users to create "pseudo-schemes"
that LWP doesn't know about, but that one of the proxy filters can handle
directly. New schemes are added as follows:
$proxy->init(); # required to get an agent
$proxy->agent->protocols_allowed(
[ @{ $proxy->agent->protocols_allowed }, 'myhttp' ] );
=item new_connection()
Increase the proxy's TCP connections counter. Only used by
L<HTTP::Proxy::Engine> objects.
( run in 0.671 second using v1.01-cache-2.11-cpan-13bb782fe5a )