summaryrefslogtreecommitdiff
path: root/lib/MooseX
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2009-06-25 15:33:29 +0200
committerfranck cuny <franck@lumberjaph.net>2009-06-25 15:33:29 +0200
commit443918302b9a9fac6c853c77ce49182be38feb6f (patch)
tree24621eb0260fa9a2d250c9906933a28bc18d4cde /lib/MooseX
parentPOD (diff)
downloadmoosex-useragent-443918302b9a9fac6c853c77ce49182be38feb6f.tar.gz
POD, add useragent string to async, tests
Diffstat (limited to 'lib/MooseX')
-rw-r--r--lib/MooseX/UserAgent/Async.pm13
-rw-r--r--lib/MooseX/UserAgent/Config.pm21
2 files changed, 22 insertions, 12 deletions
diff --git a/lib/MooseX/UserAgent/Async.pm b/lib/MooseX/UserAgent/Async.pm
index 186a183..666e804 100644
--- a/lib/MooseX/UserAgent/Async.pm
+++ b/lib/MooseX/UserAgent/Async.pm
@@ -11,23 +11,28 @@ sub fetch {
my ( $self, $url ) = @_;
my $status = AnyEvent->condvar;
+ $AnyEvent::HTTP::USERAGENT = $self->useragent_conf->{name};
+
my $last_modified = $self->get_ua_cache($url);
my $request_headers = { 'Accept-Encoding' => 'gzip', };
$request_headers->{'If-Modified-Since'} = $last_modified
if $last_modified;
- http_request GET => $url, headers => $request_headers, sub {
+ http_request
+ GET => $url,
+ headers => $request_headers,
+ sub {
my ( $data, $headers ) = @_;
my $response = HTTP::Response->new;
$response->content($data);
- $response->code(delete $headers->{Status});
+ $response->code( delete $headers->{Status} );
foreach my $header ( keys %$headers ) {
$response->header( $header => $headers->{$header} );
}
- $self->store_ua_cache($url, $response);
+ $self->store_ua_cache( $url, $response );
$status->send($response);
- };
+ };
return $status->recv;
}
diff --git a/lib/MooseX/UserAgent/Config.pm b/lib/MooseX/UserAgent/Config.pm
index d5d6730..1195aee 100644
--- a/lib/MooseX/UserAgent/Config.pm
+++ b/lib/MooseX/UserAgent/Config.pm
@@ -16,7 +16,7 @@ has 'agent' => (
$ua->agent( $conf->{name} ) if $conf->{name};
$ua->from( $conf->{mail} ) if $conf->{mail};
$ua->max_size( $conf->{max_size} || 3000000 );
- $ua->timeout( $conf->{timeout} || 30 );
+ $ua->timeout( $conf->{timeout} || 180 );
$ua;
}
);
@@ -55,21 +55,21 @@ RTGI::Role::UserAgent::Config
=item B<name>
UserAgent string used by the HTTP client. Default is to use the LWP or
-AnyEvent::HTTP string.
+AnyEvent::HTTP string. See L<LWP::UserAgent> or L<AnyEvent::HTTP>.
=item B<mail>
Mail string used by the HTTP client (only for LWP). Default is to use the
-LWP string.
+LWP string. See L<LWP::UserAgent>
=item B<max_size>
-Max size that will be fetched by the useragent, in octets (only for LWP).
-Default is set to 3 000 000.
+size limit for response content. The default is 3 000 000 octets. See
+L<LWP::UserAgent>.
=item B<timeout>
-Time out. Default is set to 30.
+Timeout value in seconds. The default timeout() value is 180 seconds
=item B<cache>
@@ -77,16 +77,21 @@ Time out. Default is set to 30.
=item B<use_cache>
-If you need caching, set to 1. Default is no cache.
+Set to true to activate caching. Defaults is false.
=item B<root>
-Where to store the cache.
+The location in the filesystem that will hold the root of the cache.
=item B<default_expires_in>
+The default expiration time for objects place in the cache. Defaults to $EXPIRES_NEVER if not explicitly set.
+
=item B<namespace>
+The namespace associated with this cache. Defaults to "Default" if not
+explicitly set.
+
=back
=back