NAME
LWP::UserAgent::Patch::LogRequestContent - Log HTTP request content (body)
VERSION
This document describes version 0.04 of LWP::UserAgent::Patch::LogRequestContent (from Perl distribution LWP-UserAgent-Patch-LogRequestContent), released on 2017-06-26.
SYNOPSIS
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.
DESCRIPTION
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.
FAQ
Why not subclass?
By patching, you do not need to replace all the client code which uses LWP (or WWW::Mechanize, etc).
Why is the request content logged before request headers (when using with Net::HTTP::Methods::Patch::LogRequest)?
Yup, it's ugly. I'm working on that.
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/LWP-UserAgent-Patch-LogRequestContent.
SOURCE
Source repository is at https://github.com/perlancar/perl-LWP-UserAgent-Patch-LogRequestContent.
BUGS
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.
SEE ALSO
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.
AUTHOR
perlancar <perlancar@cpan.org>
COPYRIGHT AND LICENSE
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.