in reply to Re: Using LWP: is there a way to get the server response time?
in thread Using LWP: is there a way to get the server response time?

I am not so familar with the LWP internals and never came to the "LWP::Protocol" branch... How would I poll LWP::Protocol::http::request()? By getting the private $sel_timeout var? A code hint would be great!

I don't want to switch over to curl...
  • Comment on Re^2: Using LWP: is there a way to get the server response time?

Replies are listed 'Best First'.
Re^3: Using LWP: is there a way to get the server response time?
by PreferredUserName (Pilgrim) on May 11, 2007 at 19:37 UTC
    OK, do a:
    locate Protocol/http.pm
    or similar to find where your LWP::Protocol::http module lives. Mine is in /usr/share/perl5/LWP/Protocol/http.pm. Search for the request() subroutine. Add these lines up at the top of it:
    use Time::HiRes qw(time); my @times;
    Add a line containing "push @times, time();" before the following three lines:
    if ($has_content) { block, ... $response = $self->collect($arg, $response, sub { ... unless ($drop_connection) {
    and then add this at the bottom:
    warn "wrote-request read-headers read-content\n@times\n";
    If this is anything but a quick hack, it might be better to subclass or otherwise hook into LWP::Protocol::http to make it more maintainable. Another approach would be to just do a HEAD and then a GET, with the difference in times being the content-transfer time.