Egg::Plugin::LWP - LWP for Egg Plugin.


Egg-Plugin-LWP documentation  | view source Contained in the Egg-Plugin-LWP distribution.

Index


NAME

Top

Egg::Plugin::LWP - LWP for Egg Plugin.

SYNOPSIS

Top

  use Egg qw/ LWP /;

  __PACKAGE__->egg_startup(
   ...
   .....

   plugin_lwp => {
     timeout => 10,
     agent   => 'MyApp Agent.',
     },

    );

  # The GET request is sent.
  my $res= $e->ua->request( GET => 'http://domain.name/hoge/' );

  # The POST request is sent.
  my $res= $e->ua->request( POST => 'http://domain.name/hoge/form', {
    param1 => 'hooo',
    param2 => 'booo',
    } );

  # It requests it GET doing to pass ua the option.
  my $res= $e->ua( agent => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)' )
             ->request( GET => 'http://domain.name/hoge/' );

  # It turns by using ua made once.
  my $ua= $e->ua( timeout => 5 );
  for my $domain (qw/ domain1 domain2 domain3 /) {
    my $res= $ua->request( GET => "http://$domain/" ) || next;
    $res->is_success || next;
    $res->...
  }

DESCRIPTION

Top

It is a plugin to use LWP::UserAgent.

Please define HASH in 'plugin_lwp' about the setting. All these set values are passed to LWP::UserAgent.

* Please refer to the document of LWP::UserAgent for the option.

METHODS

Top

ua ( [UA_OPTION_HASH] )

The handler object of Egg::Plugin::LWP is returned.

When UA_OPTION_HASH is given, everything is passed to LWP::UserAgent as an option.

UA_OPTION_HASH overwrites a set value of default.

HANDLER METHODS

Top

new

It is a constructor who is called by $e->ua.

LWP::UserAgent object is generated here.

request ( [REQUEST_METHOD], [URL], [ARGS_HASH] )

The request is sent based on generated ua.

When an invalid value to REQUEST_METHOD is passed, it treats as GET request.

URL is not omissible. The exception is generated when omitting it.

ARGS_HASH is treated as an argument passed to HTTP::Request::Common.

HTTP::Response object that ua returns after completing the request is returned.

  my $res= $e->ua->request(0, 'http://domain.name/');

simple_request

Simple_request of LWP::UserAgent is done.

The argument and others is similar to 'request' method.

  my $res= $e->ua->simple_request(0, 'http://domain.name/');

SEE ALSO

Top

Egg::Release, LWP::UserAgent, HTTP::Request::Common,

AUTHOR

Top

Masatoshi Mizuno <lushe&64;cpan.org>

COPYRIGHT AND LICENSE

Top


Egg-Plugin-LWP documentation  | view source Contained in the Egg-Plugin-LWP distribution.