GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
HTTP::Proxy::HeaderFilter(3) User Contributed Perl Documentation HTTP::Proxy::HeaderFilter(3)

HTTP::Proxy::HeaderFilter - A base class for HTTP message header filters

    package MyFilter;

    use base qw( HTTP::Proxy::HeaderFilter );

    # changes the User-Agent header in all requests
    # this filter must be pushed on the request stack
    sub filter {
        my ( $self, $headers, $message ) = @_;

        $message->headers->header( User_Agent => 'MyFilter/1.0' );
    }

    1;

The HTTP::Proxy::HeaderFilter class is used to create filters for HTTP request/response headers.

A HeaderFilter is just a derived class that implements some methods called by the proxy. Of all the methods presented below, only "filter()" must be defined in the derived class.
filter()
The signature of the "filter()" method is the following:

    sub filter { my ( $self, $headers, $message) = @_; ... }
    

where $self is the filter object, $headers is a HTTP::Headers object, and $message is either a HTTP::Request or a HTTP::Response object.

The $headers HTTP::Headers object is the one that will be sent to the client (if the filter is on the response stack) or origin server (if the filter is on the request stack). If $headers is modified by the filter, the modified headers will be sent to the client or server.

The "init()" method (if it exists) is called by the "new()" constructeur to perform all initisalisation tasks. It's called once in the filter lifetime.

A HTTP::Proxy::HeaderFilter object is a blessed hash, and the base class reserves only hash keys that start with "_hphf".

new()
The constructor is defined for all subclasses. Initialisation tasks (if any) for subclasses should be done in the "init()" method (see below).
init()
This method is called by the "new()" constructeur to perform all initisalisation tasks. It's called once in the filter lifetime.

It receives all the parameters passed to "new()".

Standard HTTP::Proxy::HeaderFilter classes are lowercase.

The following HeaderFilters are included in the HTTP::Proxy distribution:

simple
This class lets you create a simple header filter from a code reference.
standard
This is the filter that provides standard headers handling for HTTP::Proxy. It is loaded automatically by HTTP::Proxy.

Please read each filter's documentation for more details about their use.

Some methods are available to filters, so that they can eventually use the little knowledge they might have of HTTP::Proxy's internals. They mostly are accessors.
proxy()
Gets a reference to the HTTP::Proxy objects that owns the filter. This gives access to some of the proxy methods.

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

HTTP::Proxy, HTTP::Proxy::BodyFilter.

Copyright 2003-2015, Philippe Bruhat.

This module is free software; you can redistribute it or modify it under the same terms as Perl itself.
2015-06-16 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.