NAME

Net::HTTP::Methods::Patch::LogRequest - Log raw HTTP requests

VERSION

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.

SYNOPSIS

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

DESCRIPTION

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";

FAQ

Why not subclass?

By patching, you do not need to replace all the client code which uses LWP (or WWW::Mechanize, etc).

How to log request content?

See LWP::UserAgent::Patch::LogRequestContent.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Net-HTTP-Methods-Patch-LogRequest.

SOURCE

Source repository is at https://github.com/perlancar/perl-Net-HTTP-Methods-Patch-LogRequest.

BUGS

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.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

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.