]>
Dogcows Code - chaz/p5-HTTP-AnyUA/blob - lib/HTTP/AnyUA/Middleware/Runtime.pm
ed1643cb6cbba60da75751425fee764e9df07e65
1 package HTTP
::AnyUA
::Middleware
::Runtime
;
2 # ABSTRACT: Middleware to determine response time
6 $any_ua->apply_middleware('Runtime');
10 This middleware adds a "runtime" field to the response, the value of which is the number of seconds
11 it took to make the request and finish the response.
16 * L<HTTP::AnyUA::Middleware>
23 our $VERSION = '9999.999'; # VERSION
25 use parent
'HTTP::AnyUA::Middleware';
32 my ($method, $url, $args) = @_;
34 my $start = [Time
::HiRes
::gettimeofday
];
36 my $resp = $self->backend->request($method, $url, $args);
38 my $handle_response = sub {
41 $resp->{runtime
} = sprintf('%.6f', Time
::HiRes
::tv_interval
($start));
46 if ($self->response_is_future) {
48 done
=> $handle_response,
49 fail
=> $handle_response,
53 $resp = $handle_response->($resp);
This page took 0.037009 seconds and 3 git commands to generate.