Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: LWP::UserAgent hacking

by Thelonius (Priest)
on Mar 04, 2006 at 19:57 UTC ( [id://534516]=note: print w/replies, xml ) Need Help??


in reply to LWP::UserAgent hacking

Here's a method that will work for chunked responses, too:
sub send_request { my($self, $request, $arg, $size) = @_; my $content_length = 0; if (ref $arg && ref $arg eq "CODE") { my $original_arg = $arg; $arg = sub { $content_length += length($_[0]); return &$original_arg(@_); }; } my $t0 = [Time::HiRes::gettimeofday]; my $response = $self->SUPER::send_request($request,$arg,$size); my $elapsed = Time::HiRes::tv_interval($t0); $content_length = length($response->content) unless $content_length; my $header_length = length($response->headers_as_string); print STDERR sprintf "%s %f %d %d %d\n", $request->uri, $elapsed, $content_length, $header_length, $content_length+$header_length; return $response; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://534516]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-06-17 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.