NAME

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

SYNOPSIS

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

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

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

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

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

AUTHOR

Masatoshi Mizuno <lushe@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2008 Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.