The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::HTTP_Proxy_IMP - HTTP proxy with the ability to inspect and modify content

SYNOPSIS

    # only use cmdline args
    App::HTTP_Proxy_IMP->new(@ARGV)->start;             
    # only use given args
    App::HTTP_Proxy_IMP->new(\%options)->start;         
    # combine cmdline args with given defaults
    App::HTTP_Proxy_IMP->new(\%options,@ARGV)->start;   

    # short for App::HTTP_Proxy_IMP->new(...)->start;
    App::HTTP_Proxy_IMP->start(...);

    # show cmdline usage
    App::HTTP_Proxy_IMP->usage();
    

DESCRIPTION

App::HTTP_Proxy_IMP implements an HTTP proxy, which can inspect and modify the HTTP header or content before forwarding. Inspection and modification is done with plugins implementing the Net::IMP interface.

The proxy is single-threaded and non-forking, but due to the event-driven model it can still process multiple connections in parallel. It is mainly intended to be used as a platform for easy prototyping of interesting ideas using IMP plugins, but should be also fast enough to be used to enhance, secure, restrict or protocol the browsing experience for small groups.

Public Methods

  • new([\%OPTIONS],[@ARGV])

    Creates a new object. The first argument might be an hash reference with options. All other arguments will be used as ARGV for cmdline parsing and might result in overwriting the defaults from OPTIONS.

    The following options and its matching cmdline arguments are defined:

    filter ARRAY | -F|--filter mod

    List of IMP filters, which should be used for inspection and modification. These can be a fully qualified name, or a short name, which need to be combined with one of the given namespace prefixes to get the full name. It can also be already an IMP factory object.

    The cmdline option can be given multiple times. If '-' is given as name on the cmdline all previously defined filters are discarded.

    impns ARRAY | --imp-ns prefix

    Namespace prefixes to make adding filters from cmdline shorter. Defaults to App::HTTP_Proxy_IMP::IMP, Net::IMP.

    The cmdline option can be given multiple times. If '-' is given at cmdline all previously defined prefixes (including defaults) are discarded.

    addr ARRAY|ip:port

    List of ip:port combinations or single ip:port. These are the local addresses where the proxy will listen.

    On the cmdline these are given as the remaining arguments, e.g. after all other options.

    The following options are only for the cmdline

    -d|--debug [RX]

    Enable debugging. If RX is given it will be used as a regular expression to restrict debugging to given packages.

    Outside the cmdline these settings can be done by setting $DEBUG and $DEBUG_RX exported by App::HTTP_Proxy_IMP::Debug.

    -T|--trace T

    Enable tracing for Net::Inspect modules. Outside the cmdline these settings can be done by setting %TRACE from the Net::Inspect::Debug package.

  • start

    Start the proxy, e.g. start listeners and process incoming connections. No arguments are expected if called on an object, but one can use the form App::HTTP_Proxy_IMP->start(@args) as a shorter alternative to App::HTTP_Proxy_IMP->new(@args)->start.

    If no return value is expected from this method it will enter into an endless loop using AnyEvent->condvar->recv. If a value is expected it will return 1, and the caller hast to enter the AnyEvent mainloop itself.

Reaction to Signals

The installs some signal handlers:

SIGUSR1

Dump current state to STDERR, e.g. active connections and their state.

SIGUSR2

Toggles debugging (e.g. enable|disable).

AUTHOR

Steffen Ullrich <sullr@cpan.org>

COPYRIGHT

Copyright 2012,2013 Steffen Ullrich.

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

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 332:

Expected '=item *'

Around line 344:

You forgot a '=back' before '=head2'