LWP::UserAgent::Patch::LogRequestContent - Log HTTP request content (body)
This document describes version 0.04 of LWP::UserAgent::Patch::LogRequestContent (from Perl distribution LWP-UserAgent-Patch-LogRequestContent), released on 2017-06-26.
use LWP::UserAgent::Patch::LogRequestContent; # now all your LWP HTTP request content are logged
Sample script and output:
% TRACE=1 perl -MLog::ger::Output=Screen -MNet::HTTP::Methods::Patch::LogRequest \ -MLWP::UserAgent::Patch::LogRequestContent \ -MLWP::UserAgent \ -e'$ua = LWP::UserAgent->new; $ua->post("http://localhost:5000/", {a=>1, b=>2});' [cat LWP.UserAgent.Patch.LogRequestContent]HTTP request body (len=7): a=1&b=2 [cat Net.HTTP.Methods.Patch.LogRequest]HTTP request (proto=http, len=186): POST / HTTP/1.1 TE: deflate,gzip;q=0.3 Connection: TE, close Host: localhost:5000 User-Agent: libwww-perl/6.04 Content-Length: 7 Content-Type: application/x-www-form-urlencoded
Or you can also use via Log::ger::For::LWP.
This module patches LWP::UserAgent (which is used by LWP::Simple, WWW::Mechanize, among others) so that HTTP request contents are logged using Log::ger.
By patching, you do not need to replace all the client code which uses LWP (or WWW::Mechanize, etc).
Yup, it's ugly. I'm working on that.
Please visit the project's homepage at https://metacpan.org/release/LWP-UserAgent-Patch-LogRequestContent.
Source repository is at https://github.com/perlancar/perl-LWP-UserAgent-Patch-LogRequestContent.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=LWP-UserAgent-Patch-LogRequestContent
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.
Use Net::HTTP::Methods::Patch::LogRequest to log raw HTTP request headers being sent to servers.
Use LWP::UserAgent::Patch::LogResponse to log HTTP responses.
Log::ger::For::LWP bundles all three mentioned patches in a single convenient package.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2017, 2016, 2015, 2013 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 LWP::UserAgent::Patch::LogRequestContent, copy and paste the appropriate command in to your terminal.
cpanm
cpanm LWP::UserAgent::Patch::LogRequestContent
CPAN shell
perl -MCPAN -e shell install LWP::UserAgent::Patch::LogRequestContent
For more information on module installation, please visit the detailed CPAN module installation guide.