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

NAME

TaskPipe::UserAgentManager - base class for managing requests in TaskPipe

DESCRIPTION

You can use this class with TaskPipe::Task_Scrape by specifying it as the useragent manager to use in your project config. The useragent handler module specified in the ua_handler_module setting in your config should provide the useragent handler TaskPipe::UserAgentManager will use. E.g.:

    TaskPipe::Task_Scrape::Settings:
        ua_mgr_module: TaskPipe::UserAgentManager
        ua_handler_module: TaskPipe::UserAgentManager::UserAgentHandler

        # ...

If you want to modify the way TaskPipe makes requests you can inherit from TaskPipe::UserAgentManager and create your own UserAgentManager. The format for your custom useragent manager might be as follows:

    package TaskPipe::UserAgentManager_MyUAManager;    
    use Moose;

    sub init{
        my ($self) = @_;

        # do something on initialisation

    }


    sub before_request($self,method,@params){
    
        # method = 'get', 'post', ...
        # params = whatever params were passed when 
        #            the request was made (url etc)
        #
        # Do something directly before the request happens

    }
     

    sub after_request($self,$resp,$method,@params){

        # resp = the HTTP::Response object
        #
        # Do something directly after the request happens

    }

    __PACKAGE__->meta->make_immutable;
    1;

SEE ALSO

If you are thinking of inheriting from TaskPipe::UserAgentManager, see the modules included in TaskPipe already for exmples of how to do this:

TaskPipe::UserAgentManager_ProxyNet TaskPipe::UserAgentManager_ProxyNet_TOR TaskPipe::UserAgentManager_ProxyNet_Open

See TaskPipe::UserAgentManager::UserAgentHandler for more information about handlers.

AUTHOR

Tom Gracey <tomgracey@gmail.com>

COPYRIGHT AND LICENSE

Copyright (c) Tom Gracey 2018

TaskPipe is free software, licensed under

    The GNU Public License Version 3