Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

HTTP::Proxy traffic calculating

by b888 (Beadle)
on Feb 22, 2005 at 11:12 UTC ( [id://433308]=perlquestion: print w/replies, xml ) Need Help??

b888 has asked for the wisdom of the Perl Monks concerning the following question:

Greetings

I there any way to log binded incoming/outgoing requests details. For now I made only separate logging (without support chunks either).

$proxy->push_filter( request => HTTP::Proxy::BodyFilter::simple->new( sub { my ( $self, $dataref, $message, $protocol, $buffer ) = @_; print "[".time_stamp()."][out ". length($message->as_string() || ''). "] ".$message->uri()."\n"; } ) ); $proxy->push_filter( response => HTTP::Proxy::BodyFilter::simple->new( sub { my ( $self, $dataref, $message, $protocol, $buffer ) = @_; if( $$dataref ){ print "[".time_stamp()."][in ". length($$dataref)."]\n"; } } ) );

Replies are listed 'Best First'.
Re: HTTP::Proxy traffic calculating
by BooK (Curate) on Feb 22, 2005 at 13:22 UTC

    $message is a HTTP::Response object when your filter is a response filter, so you can access the request via $message->request(). This should let you compute your stats in the response filter.

    Please note that HTTP::Proxy does currently behave well with large request bodies: it loads the whole request body in memory before processing and sending it to the next hop. This is more than often okay, except when you upload very laaaarge files.

      The main problem is that incoming data (response from external sources) comes to defined filter in chunks. For example for google.com there are 4 chunks, means 4 calls of sub defined in

      $proxy->push_filter(response => ...

      And $$buffer value seems desapearing in last (always 0-sized) chunk.

      p.s. Thanks for great component :)

      Broken code tag repaired by davido.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found