Net::HTTP::Methods::Patch::LogRequest - Log raw HTTP requests
This document describes version 0.11 of Net::HTTP::Methods::Patch::LogRequest (from Perl distribution Net-HTTP-Methods-Patch-LogRequest), released on 2018-04-26.
use Net::HTTP::Methods::Patch::LogRequest; # now all your LWP HTTP requests are logged
Sample script and output:
% LOG_SHOW_CATEGORY=1 TRACE=1 perl -MLog::ger::Output=Screen \ -MNet::HTTP::Methods::Patch::LogRequest -MWWW::Mechanize \ -e'$mech=WWW::Mechanize->new; $mech->get("http://www.google.com/")' [cat Net.HTTP.Methods.Patch.LogRequest][23] HTTP request (142 bytes): GET / HTTP/1.1 TE: deflate,gzip;q=0.3 Connection: TE, close Accept-Encoding: gzip Host: www.google.com User-Agent: WWW-Mechanize/1.71 [cat Net.HTTP.Methods.Patch.LogRequest][70] HTTP request (144 bytes): GET / HTTP/1.1 TE: deflate,gzip;q=0.3 Connection: TE, close Accept-Encoding: gzip Host: www.google.co.id User-Agent: WWW-Mechanize/1.71
This module patches Net::HTTP::Methods so that raw LWP HTTP request is logged using Log::ger. If you look into LWP::Protocol::http's source code, you'll see that it is already doing that (albeit commented):
my $req_buf = $socket->format_request($method, $fullpath, @h); #print "------\n$req_buf\n------\n";
By patching, you do not need to replace all the client code which uses LWP (or WWW::Mechanize, etc).
See LWP::UserAgent::Patch::LogRequestContent.
Please visit the project's homepage at https://metacpan.org/release/Net-HTTP-Methods-Patch-LogRequest.
Source repository is at https://github.com/perlancar/perl-Net-HTTP-Methods-Patch-LogRequest.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Net-HTTP-Methods-Patch-LogRequest
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2018, 2017, 2015, 2012 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Net::HTTP::Methods::Patch::LogRequest, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::HTTP::Methods::Patch::LogRequest
CPAN shell
perl -MCPAN -e shell install Net::HTTP::Methods::Patch::LogRequest
For more information on module installation, please visit the detailed CPAN module installation guide.