From 18697ed4e19ab47a9b272b7c314b6580e89c1cc2 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Thu, 21 Jul 2022 11:28:24 +0900 Subject: [PATCH] Imported Upstream version 6.39 --- Changes | 5 + INSTALL | 6 +- MANIFEST | 1 + META.json | 72 +++++++------ META.yml | 70 ++++++------ Makefile.PL | 6 +- dist.ini | 1 + examples/handler-order.pl | 21 ++++ lib/LWP.pm | 2 +- lib/LWP/Authen/Basic.pm | 2 +- lib/LWP/Authen/Digest.pm | 2 +- lib/LWP/Authen/Ntlm.pm | 2 +- lib/LWP/ConnCache.pm | 2 +- lib/LWP/Debug.pm | 2 +- lib/LWP/Debug/TraceHTTP.pm | 2 +- lib/LWP/DebugFile.pm | 2 +- lib/LWP/MemberMixin.pm | 2 +- lib/LWP/Protocol.pm | 2 +- lib/LWP/Protocol/cpan.pm | 2 +- lib/LWP/Protocol/data.pm | 2 +- lib/LWP/Protocol/file.pm | 2 +- lib/LWP/Protocol/ftp.pm | 2 +- lib/LWP/Protocol/gopher.pm | 2 +- lib/LWP/Protocol/http.pm | 2 +- lib/LWP/Protocol/loopback.pm | 2 +- lib/LWP/Protocol/mailto.pm | 2 +- lib/LWP/Protocol/nntp.pm | 2 +- lib/LWP/Protocol/nogo.pm | 2 +- lib/LWP/RobotUA.pm | 2 +- lib/LWP/Simple.pm | 2 +- lib/LWP/UserAgent.pm | 180 +++++++++++++++++++++++-------- t/base/protocols/nntp.t | 2 +- xt/release/changes_has_content.t | 2 +- 33 files changed, 267 insertions(+), 143 deletions(-) create mode 100755 examples/handler-order.pl diff --git a/Changes b/Changes index 566e701..ac21915 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,10 @@ Change history for libwww-perl +6.39 2019-05-06 14:18:39Z + - Document current best practices (GH#314) (Olaf Alders) + - Document order in which handlers fire (GH#315) (Olaf Alders) + - SKIP nntp test for now (GH#317) (Olaf Alders) + 6.38 2019-03-25 18:58:58Z - Update Net::HTTP dependency from 6.07 to 6.18 (GH#310) (Olaf Alders) - Remove s.c.o. from SYNOPSIS (GH#308) (Olaf Alders) diff --git a/INSTALL b/INSTALL index c24b514..48656c3 100644 --- a/INSTALL +++ b/INSTALL @@ -6,7 +6,7 @@ Installing libwww-perl is straightforward. If you have cpanm, you only need one line: - % cpanm libwww::perl + % cpanm LWP If it does not have permission to install modules to the current perl, cpanm will automatically set up and install to a local::lib in your home directory. @@ -17,7 +17,7 @@ details on enabling it in your environment. Alternatively, if your CPAN shell is set up, you should just be able to do: - % cpan libwww::perl + % cpan LWP ## Manual installation @@ -66,7 +66,7 @@ They can all be found in the "PHASE_requires" key of MYMETA.yml or the libwww-perl documentation is available as POD. You can run `perldoc` from a shell to read the documentation: - % perldoc libwww::perl + % perldoc LWP For more information on installing Perl modules via CPAN, please see: https://www.cpan.org/modules/INSTALL.html diff --git a/MANIFEST b/MANIFEST index bae6b69..b937f70 100644 --- a/MANIFEST +++ b/MANIFEST @@ -14,6 +14,7 @@ bin/lwp-mirror bin/lwp-request cpanfile dist.ini +examples/handler-order.pl lib/LWP.pm lib/LWP/Authen/Basic.pm lib/LWP/Authen/Digest.pm diff --git a/META.json b/META.json index 70b961b..ed68c82 100644 --- a/META.json +++ b/META.json @@ -108,96 +108,96 @@ "provides" : { "LWP" : { "file" : "lib/LWP.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Authen::Basic" : { "file" : "lib/LWP/Authen/Basic.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Authen::Digest" : { "file" : "lib/LWP/Authen/Digest.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Authen::Ntlm" : { "file" : "lib/LWP/Authen/Ntlm.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::ConnCache" : { "file" : "lib/LWP/ConnCache.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Debug" : { "file" : "lib/LWP/Debug.pm", - "version" : "6.38", + "version" : "6.39", "x_deprecated" : 1 }, "LWP::Debug::TraceHTTP" : { "file" : "lib/LWP/Debug/TraceHTTP.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::DebugFile" : { "file" : "lib/LWP/DebugFile.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::MemberMixin" : { "file" : "lib/LWP/MemberMixin.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Protocol" : { "file" : "lib/LWP/Protocol.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Protocol::cpan" : { "file" : "lib/LWP/Protocol/cpan.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Protocol::data" : { "file" : "lib/LWP/Protocol/data.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Protocol::file" : { "file" : "lib/LWP/Protocol/file.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Protocol::ftp" : { "file" : "lib/LWP/Protocol/ftp.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Protocol::gopher" : { "file" : "lib/LWP/Protocol/gopher.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Protocol::http" : { "file" : "lib/LWP/Protocol/http.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Protocol::loopback" : { "file" : "lib/LWP/Protocol/loopback.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Protocol::mailto" : { "file" : "lib/LWP/Protocol/mailto.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Protocol::nntp" : { "file" : "lib/LWP/Protocol/nntp.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Protocol::nogo" : { "file" : "lib/LWP/Protocol/nogo.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::RobotUA" : { "file" : "lib/LWP/RobotUA.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::Simple" : { "file" : "lib/LWP/Simple.pm", - "version" : "6.38" + "version" : "6.39" }, "LWP::UserAgent" : { "file" : "lib/LWP/UserAgent.pm", - "version" : "6.38" + "version" : "6.39" } }, "release_status" : "stable", @@ -214,7 +214,7 @@ "x_IRC" : "irc://irc.perl.org/#lwp", "x_MailingList" : "mailto:libwww@perl.org" }, - "version" : "6.38", + "version" : "6.39", "x_Dist_Zilla" : { "perl" : { "version" : "5.026001" @@ -312,7 +312,7 @@ "class" : "Dist::Zilla::Plugin::Git::Contributors", "config" : { "Dist::Zilla::Plugin::Git::Contributors" : { - "git_version" : "2.20.1", + "git_version" : "2.21.0", "include_authors" : 0, "include_releaser" : 1, "order_by" : "name", @@ -344,8 +344,14 @@ }, { "class" : "Dist::Zilla::Plugin::InstallGuide", + "config" : { + "Dist::Zilla::Role::ModuleMetadata" : { + "Module::Metadata" : "1.000033", + "version" : "0.004" + } + }, "name" : "InstallGuide", - "version" : "1.200012" + "version" : "1.200013" }, { "class" : "Dist::Zilla::Plugin::ExecDir", @@ -381,7 +387,7 @@ } }, "name" : "MakeMaker::Awesome", - "version" : "0.41" + "version" : "0.47" }, { "class" : "Dist::Zilla::Plugin::MojibakeTests", @@ -621,7 +627,7 @@ "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { - "git_version" : "2.20.1", + "git_version" : "2.21.0", "repo_root" : "." } }, @@ -751,7 +757,7 @@ "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { - "git_version" : "2.20.1", + "git_version" : "2.21.0", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { @@ -768,12 +774,12 @@ "branch" : null, "changelog" : "Changes", "signed" : 0, - "tag" : "v6.38", + "tag" : "v6.39", "tag_format" : "v%V", "tag_message" : "v%V" }, "Dist::Zilla::Role::Git::Repo" : { - "git_version" : "2.20.1", + "git_version" : "2.21.0", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { @@ -823,7 +829,7 @@ "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { - "git_version" : "2.20.1", + "git_version" : "2.21.0", "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { @@ -843,7 +849,7 @@ "remotes_must_exist" : 1 }, "Dist::Zilla::Role::Git::Repo" : { - "git_version" : "2.20.1", + "git_version" : "2.21.0", "repo_root" : "." } }, diff --git a/META.yml b/META.yml index 461596c..0173f02 100644 --- a/META.yml +++ b/META.yml @@ -30,74 +30,74 @@ no_index: provides: LWP: file: lib/LWP.pm - version: '6.38' + version: '6.39' LWP::Authen::Basic: file: lib/LWP/Authen/Basic.pm - version: '6.38' + version: '6.39' LWP::Authen::Digest: file: lib/LWP/Authen/Digest.pm - version: '6.38' + version: '6.39' LWP::Authen::Ntlm: file: lib/LWP/Authen/Ntlm.pm - version: '6.38' + version: '6.39' LWP::ConnCache: file: lib/LWP/ConnCache.pm - version: '6.38' + version: '6.39' LWP::Debug: file: lib/LWP/Debug.pm - version: '6.38' + version: '6.39' x_deprecated: 1 LWP::Debug::TraceHTTP: file: lib/LWP/Debug/TraceHTTP.pm - version: '6.38' + version: '6.39' LWP::DebugFile: file: lib/LWP/DebugFile.pm - version: '6.38' + version: '6.39' LWP::MemberMixin: file: lib/LWP/MemberMixin.pm - version: '6.38' + version: '6.39' LWP::Protocol: file: lib/LWP/Protocol.pm - version: '6.38' + version: '6.39' LWP::Protocol::cpan: file: lib/LWP/Protocol/cpan.pm - version: '6.38' + version: '6.39' LWP::Protocol::data: file: lib/LWP/Protocol/data.pm - version: '6.38' + version: '6.39' LWP::Protocol::file: file: lib/LWP/Protocol/file.pm - version: '6.38' + version: '6.39' LWP::Protocol::ftp: file: lib/LWP/Protocol/ftp.pm - version: '6.38' + version: '6.39' LWP::Protocol::gopher: file: lib/LWP/Protocol/gopher.pm - version: '6.38' + version: '6.39' LWP::Protocol::http: file: lib/LWP/Protocol/http.pm - version: '6.38' + version: '6.39' LWP::Protocol::loopback: file: lib/LWP/Protocol/loopback.pm - version: '6.38' + version: '6.39' LWP::Protocol::mailto: file: lib/LWP/Protocol/mailto.pm - version: '6.38' + version: '6.39' LWP::Protocol::nntp: file: lib/LWP/Protocol/nntp.pm - version: '6.38' + version: '6.39' LWP::Protocol::nogo: file: lib/LWP/Protocol/nogo.pm - version: '6.38' + version: '6.39' LWP::RobotUA: file: lib/LWP/RobotUA.pm - version: '6.38' + version: '6.39' LWP::Simple: file: lib/LWP/Simple.pm - version: '6.38' + version: '6.39' LWP::UserAgent: file: lib/LWP/UserAgent.pm - version: '6.38' + version: '6.39' requires: Digest::MD5: '0' Encode: '2.12' @@ -134,7 +134,7 @@ resources: bugtracker: https://github.com/libwww-perl/libwww-perl/issues homepage: https://github.com/libwww-perl/libwww-perl repository: https://github.com/libwww-perl/libwww-perl.git -version: '6.38' +version: '6.39' x_Dist_Zilla: perl: version: '5.026001' @@ -210,7 +210,7 @@ x_Dist_Zilla: class: Dist::Zilla::Plugin::Git::Contributors config: Dist::Zilla::Plugin::Git::Contributors: - git_version: 2.20.1 + git_version: 2.21.0 include_authors: 0 include_releaser: 1 order_by: name @@ -235,8 +235,12 @@ x_Dist_Zilla: version: '6.012' - class: Dist::Zilla::Plugin::InstallGuide + config: + Dist::Zilla::Role::ModuleMetadata: + Module::Metadata: '1.000033' + version: '0.004' name: InstallGuide - version: '1.200012' + version: '1.200013' - class: Dist::Zilla::Plugin::ExecDir name: ExecDir @@ -263,7 +267,7 @@ x_Dist_Zilla: default_jobs: 1 version: '6.012' name: MakeMaker::Awesome - version: '0.41' + version: '0.47' - class: Dist::Zilla::Plugin::MojibakeTests name: MojibakeTests @@ -474,7 +478,7 @@ x_Dist_Zilla: allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: - git_version: 2.20.1 + git_version: 2.21.0 repo_root: . name: Git::Check version: '2.046' @@ -571,7 +575,7 @@ x_Dist_Zilla: allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: - git_version: 2.20.1 + git_version: 2.21.0 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local @@ -584,11 +588,11 @@ x_Dist_Zilla: branch: ~ changelog: Changes signed: 0 - tag: v6.38 + tag: v6.39 tag_format: v%V tag_message: v%V Dist::Zilla::Role::Git::Repo: - git_version: 2.20.1 + git_version: 2.21.0 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local @@ -625,7 +629,7 @@ x_Dist_Zilla: - (?^:^lib/.*\.pm$) changelog: Changes Dist::Zilla::Role::Git::Repo: - git_version: 2.20.1 + git_version: 2.21.0 repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local @@ -639,7 +643,7 @@ x_Dist_Zilla: - origin remotes_must_exist: 1 Dist::Zilla::Role::Git::Repo: - git_version: 2.20.1 + git_version: 2.21.0 repo_root: . name: Git::Push version: '2.046' diff --git a/Makefile.PL b/Makefile.PL index 1213e1b..67b0ccf 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,5 +1,5 @@ # This Makefile.PL for libwww-perl was generated by -# Dist::Zilla::Plugin::MakeMaker::Awesome 0.41. +# Dist::Zilla::Plugin::MakeMaker::Awesome 0.47. # Don't edit it but the dist.ini and plugins used to construct it. use strict; @@ -86,7 +86,7 @@ my %WriteMakefileArgs = ( "Test::Needs" => 0, "Test::RequiresInternet" => 0 }, - "VERSION" => "6.38", + "VERSION" => "6.39", "test" => { "TESTS" => "t/*.t t/base/*.t t/base/protocols/*.t t/leak/*.t t/local/*.t t/robot/*.t" } @@ -138,7 +138,7 @@ my %FallbackPrereqs = ( # inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.034 requires('HTTP::Status', '6.18') if has_module('HTTP::Status', '6.17'); -unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { +unless ( eval { ExtUtils::MakeMaker->VERSION('6.63_03') } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; diff --git a/dist.ini b/dist.ini index 206206f..f52d2a2 100644 --- a/dist.ini +++ b/dist.ini @@ -33,6 +33,7 @@ authority = cpan:LWWWP [Manifest] [License] [InstallGuide] +:version = 1.200013 ; make the bin dir executables [ExecDir] diff --git a/examples/handler-order.pl b/examples/handler-order.pl new file mode 100755 index 0000000..813fac7 --- /dev/null +++ b/examples/handler-order.pl @@ -0,0 +1,21 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use feature qw( say ); + +use LWP::UserAgent; +my $ua = LWP::UserAgent->new; + +my @phases = ( + 'request_preprepare', 'request_prepare', + 'request_send', 'response_header', + 'response_data', 'response_done', + 'response_redirect', +); + +for my $phase (@phases) { + $ua->add_handler($phase => sub { say "$phase"; return undef; }); +} + +$ua->get('http://example.com'); diff --git a/lib/LWP.pm b/lib/LWP.pm index 6bd840e..47a8e20 100644 --- a/lib/LWP.pm +++ b/lib/LWP.pm @@ -1,6 +1,6 @@ package LWP; -our $VERSION = '6.38'; +our $VERSION = '6.39'; require LWP::UserAgent; # this should load everything you need diff --git a/lib/LWP/Authen/Basic.pm b/lib/LWP/Authen/Basic.pm index f11b716..f24a3e5 100644 --- a/lib/LWP/Authen/Basic.pm +++ b/lib/LWP/Authen/Basic.pm @@ -2,7 +2,7 @@ package LWP::Authen::Basic; use strict; -our $VERSION = '6.38'; +our $VERSION = '6.39'; require MIME::Base64; diff --git a/lib/LWP/Authen/Digest.pm b/lib/LWP/Authen/Digest.pm index 70fba9a..0376d15 100644 --- a/lib/LWP/Authen/Digest.pm +++ b/lib/LWP/Authen/Digest.pm @@ -3,7 +3,7 @@ package LWP::Authen::Digest; use strict; use base 'LWP::Authen::Basic'; -our $VERSION = '6.38'; +our $VERSION = '6.39'; require Digest::MD5; diff --git a/lib/LWP/Authen/Ntlm.pm b/lib/LWP/Authen/Ntlm.pm index f75fe13..0808e76 100644 --- a/lib/LWP/Authen/Ntlm.pm +++ b/lib/LWP/Authen/Ntlm.pm @@ -2,7 +2,7 @@ package LWP::Authen::Ntlm; use strict; -our $VERSION = '6.38'; +our $VERSION = '6.39'; use Authen::NTLM "1.02"; use MIME::Base64 "2.12"; diff --git a/lib/LWP/ConnCache.pm b/lib/LWP/ConnCache.pm index d4a075c..63e7088 100644 --- a/lib/LWP/ConnCache.pm +++ b/lib/LWP/ConnCache.pm @@ -2,7 +2,7 @@ package LWP::ConnCache; use strict; -our $VERSION = '6.38'; +our $VERSION = '6.39'; our $DEBUG; sub new { diff --git a/lib/LWP/Debug.pm b/lib/LWP/Debug.pm index 502cd91..ddf7fc1 100644 --- a/lib/LWP/Debug.pm +++ b/lib/LWP/Debug.pm @@ -1,6 +1,6 @@ package LWP::Debug; # legacy -our $VERSION = '6.38'; +our $VERSION = '6.39'; require Exporter; our @ISA = qw(Exporter); diff --git a/lib/LWP/Debug/TraceHTTP.pm b/lib/LWP/Debug/TraceHTTP.pm index fa45df1..1b1ffca 100644 --- a/lib/LWP/Debug/TraceHTTP.pm +++ b/lib/LWP/Debug/TraceHTTP.pm @@ -11,7 +11,7 @@ package LWP::Debug::TraceHTTP; use strict; use base 'LWP::Protocol::http'; -our $VERSION = '6.38'; +our $VERSION = '6.39'; package # hide from PAUSE LWP::Debug::TraceHTTP::Socket; diff --git a/lib/LWP/DebugFile.pm b/lib/LWP/DebugFile.pm index c53e63a..d5762f6 100644 --- a/lib/LWP/DebugFile.pm +++ b/lib/LWP/DebugFile.pm @@ -1,6 +1,6 @@ package LWP::DebugFile; -our $VERSION = '6.38'; +our $VERSION = '6.39'; # legacy stub diff --git a/lib/LWP/MemberMixin.pm b/lib/LWP/MemberMixin.pm index 278d00f..965b94f 100644 --- a/lib/LWP/MemberMixin.pm +++ b/lib/LWP/MemberMixin.pm @@ -1,6 +1,6 @@ package LWP::MemberMixin; -our $VERSION = '6.38'; +our $VERSION = '6.39'; sub _elem { my $self = shift; diff --git a/lib/LWP/Protocol.pm b/lib/LWP/Protocol.pm index 5082841..dff69ac 100644 --- a/lib/LWP/Protocol.pm +++ b/lib/LWP/Protocol.pm @@ -2,7 +2,7 @@ package LWP::Protocol; use base 'LWP::MemberMixin'; -our $VERSION = '6.38'; +our $VERSION = '6.39'; use strict; use Carp (); diff --git a/lib/LWP/Protocol/cpan.pm b/lib/LWP/Protocol/cpan.pm index 491e6b4..12e2ce9 100644 --- a/lib/LWP/Protocol/cpan.pm +++ b/lib/LWP/Protocol/cpan.pm @@ -4,7 +4,7 @@ use strict; use base qw(LWP::Protocol); -our $VERSION = '6.38'; +our $VERSION = '6.39'; require URI; require HTTP::Status; diff --git a/lib/LWP/Protocol/data.pm b/lib/LWP/Protocol/data.pm index d1ba58c..186cea0 100644 --- a/lib/LWP/Protocol/data.pm +++ b/lib/LWP/Protocol/data.pm @@ -4,7 +4,7 @@ package LWP::Protocol::data; use strict; -our $VERSION = '6.38'; +our $VERSION = '6.39'; require HTTP::Response; require HTTP::Status; diff --git a/lib/LWP/Protocol/file.pm b/lib/LWP/Protocol/file.pm index 5f8c7d8..18a11ed 100644 --- a/lib/LWP/Protocol/file.pm +++ b/lib/LWP/Protocol/file.pm @@ -4,7 +4,7 @@ use base qw(LWP::Protocol); use strict; -our $VERSION = '6.38'; +our $VERSION = '6.39'; require LWP::MediaTypes; require HTTP::Request; diff --git a/lib/LWP/Protocol/ftp.pm b/lib/LWP/Protocol/ftp.pm index 2f4b44c..9bd705a 100644 --- a/lib/LWP/Protocol/ftp.pm +++ b/lib/LWP/Protocol/ftp.pm @@ -5,7 +5,7 @@ package LWP::Protocol::ftp; use base qw(LWP::Protocol); use strict; -our $VERSION = '6.38'; +our $VERSION = '6.39'; use Carp (); use HTTP::Status (); diff --git a/lib/LWP/Protocol/gopher.pm b/lib/LWP/Protocol/gopher.pm index e9457ee..a89ad28 100644 --- a/lib/LWP/Protocol/gopher.pm +++ b/lib/LWP/Protocol/gopher.pm @@ -9,7 +9,7 @@ package LWP::Protocol::gopher; use strict; -our $VERSION = '6.38'; +our $VERSION = '6.39'; require HTTP::Response; require HTTP::Status; diff --git a/lib/LWP/Protocol/http.pm b/lib/LWP/Protocol/http.pm index 566a558..9aaf198 100644 --- a/lib/LWP/Protocol/http.pm +++ b/lib/LWP/Protocol/http.pm @@ -2,7 +2,7 @@ package LWP::Protocol::http; use strict; -our $VERSION = '6.38'; +our $VERSION = '6.39'; require HTTP::Response; require HTTP::Status; diff --git a/lib/LWP/Protocol/loopback.pm b/lib/LWP/Protocol/loopback.pm index 52dda1f..d50fa53 100644 --- a/lib/LWP/Protocol/loopback.pm +++ b/lib/LWP/Protocol/loopback.pm @@ -2,7 +2,7 @@ package LWP::Protocol::loopback; use strict; -our $VERSION = '6.38'; +our $VERSION = '6.39'; require HTTP::Response; diff --git a/lib/LWP/Protocol/mailto.pm b/lib/LWP/Protocol/mailto.pm index ba97b9a..6e205ec 100644 --- a/lib/LWP/Protocol/mailto.pm +++ b/lib/LWP/Protocol/mailto.pm @@ -11,7 +11,7 @@ require HTTP::Status; use Carp; use strict; -our $VERSION = '6.38'; +our $VERSION = '6.39'; use base qw(LWP::Protocol); our $SENDMAIL; diff --git a/lib/LWP/Protocol/nntp.pm b/lib/LWP/Protocol/nntp.pm index c271d6b..e69330f 100644 --- a/lib/LWP/Protocol/nntp.pm +++ b/lib/LWP/Protocol/nntp.pm @@ -4,7 +4,7 @@ package LWP::Protocol::nntp; use base qw(LWP::Protocol); -our $VERSION = '6.38'; +our $VERSION = '6.39'; require HTTP::Response; require HTTP::Status; diff --git a/lib/LWP/Protocol/nogo.pm b/lib/LWP/Protocol/nogo.pm index 1b7cc3b..a362fae 100644 --- a/lib/LWP/Protocol/nogo.pm +++ b/lib/LWP/Protocol/nogo.pm @@ -7,7 +7,7 @@ package LWP::Protocol::nogo; use strict; -our $VERSION = '6.38'; +our $VERSION = '6.39'; require HTTP::Response; require HTTP::Status; diff --git a/lib/LWP/RobotUA.pm b/lib/LWP/RobotUA.pm index 720d3f3..c2b4651 100644 --- a/lib/LWP/RobotUA.pm +++ b/lib/LWP/RobotUA.pm @@ -2,7 +2,7 @@ package LWP::RobotUA; use base qw(LWP::UserAgent); -our $VERSION = '6.38'; +our $VERSION = '6.39'; require WWW::RobotRules; require HTTP::Request; diff --git a/lib/LWP/Simple.pm b/lib/LWP/Simple.pm index a33e4d5..75cb7d0 100644 --- a/lib/LWP/Simple.pm +++ b/lib/LWP/Simple.pm @@ -2,7 +2,7 @@ package LWP::Simple; use strict; -our $VERSION = '6.38'; +our $VERSION = '6.39'; require Exporter; diff --git a/lib/LWP/UserAgent.pm b/lib/LWP/UserAgent.pm index e9b4dcf..3690bd5 100644 --- a/lib/LWP/UserAgent.pm +++ b/lib/LWP/UserAgent.pm @@ -15,7 +15,7 @@ use LWP::Protocol (); use Scalar::Util qw(blessed); use Try::Tiny qw(try catch); -our $VERSION = '6.38'; +our $VERSION = '6.39'; sub new { @@ -1133,22 +1133,48 @@ LWP::UserAgent - Web user agent class =head1 SYNOPSIS - use strict; - use warnings; - use LWP::UserAgent (); + use strict; + use warnings; - my $ua = LWP::UserAgent->new; - $ua->timeout(10); - $ua->env_proxy; + use LWP::UserAgent (); - my $response = $ua->get('http://example.com'); + my $ua = LWP::UserAgent->new(timeout => 10); + $ua->env_proxy; + + my $response = $ua->get('http://example.com'); + + if ($response->is_success) { + print $response->decoded_content; + } + else { + die $response->status_line; + } + +Extra layers of security (note the C and C): + + use strict; + use warnings; + + use HTTP::CookieJar::LWP (); + use LWP::UserAgent (); + + my $jar = HTTP::CookieJar::LWP->new; + my $ua = LWP::UserAgent->new( + cookie_jar => $jar, + protocols_allowed => ['http', 'https'], + timeout => 10, + ); + + $ua->env_proxy; - if ($response->is_success) { - print $response->decoded_content; # or whatever - } - else { - die $response->status_line; - } + my $response = $ua->get('http://example.com'); + + if ($response->is_success) { + print $response->decoded_content; + } + else { + die $response->status_line; + } =head1 DESCRIPTION @@ -1276,7 +1302,16 @@ the cookie jar object must implement the C and C methods. These methods will then be invoked by the user agent as requests are sent and responses are received. Normally this will be a L object or some -subclass. +subclass. You are, however, encouraged to use L +instead. See L for more information. + + use HTTP::CookieJar::LWP (); + + my $jar = HTTP::CookieJar::LWP->new; + my $ua = LWP::UserAgent->new( cookie_jar => $jar ); + + # or after object creation + $ua->cookie_jar( $cookie_jar ); The default is to have no cookie jar, i.e. never automatically add C headers to the requests. @@ -1592,34 +1627,27 @@ the active handlers: Add handler to be invoked in the given processing phase. For how to specify C<%matchspec> see L. -The possible values C<$phase> and the corresponding callback signatures are: - -=over - -=item response_data => sub { my($response, $ua, $handler, $data) = @_; ... } - -This handler is called for each chunk of data received for the -response. The handler might croak to abort the request. - -This handler needs to return a TRUE value to be called again for -subsequent chunks for the same request. - -=item response_done => sub { my($response, $ua, $handler) = @_; ... } +The possible values C<$phase> and the corresponding callback signatures are as +follows. Note that the handlers are documented in the order in which they will +be run, which is: -The handler is called after the response has been fully received, but -before any redirect handling is attempted. The handler can be used to -extract information or modify the response. + request_preprepare + request_prepare + request_send + response_header + response_data + response_done + response_redirect -=item response_header => sub { my($response, $ua, $handler) = @_; ... } +=over -This handler is called right after the response headers have been -received, but before any content data. The handler might set up -handlers for data and might croak to abort the request. +=item request_preprepare => sub { my($request, $ua, $handler) = @_; ... } -The handler might set the C<< $response->{default_add_content} >> value to -control if any received data should be added to the response object -directly. This will initially be false if the C<< $ua->request() >> method -was called with a C<$content_file> or C<$content_cb argument>; otherwise true. +The handler is called before the C and other standard +initialization of the request. This can be used to set up headers +and attributes that the C handler depends on. Proxy +initialization should take place here; but in general don't register +handlers for this phase. =item request_prepare => sub { my($request, $ua, $handler) = @_; ... } @@ -1634,14 +1662,6 @@ The return value from the callback is ignored. If an exception is raised it will abort the request and make the request method return a "400 Bad request" response. -=item request_preprepare => sub { my($request, $ua, $handler) = @_; ... } - -The handler is called before the C and other standard -initialization of the request. This can be used to set up headers -and attributes that the C handler depends on. Proxy -initialization should take place here; but in general don't register -handlers for this phase. - =item request_send => sub { my($request, $ua, $handler) = @_; ... } This handler gets a chance of handling requests before they're sent to the @@ -1651,6 +1671,31 @@ wishes to terminate the processing; otherwise it should return nothing. The C and C handlers will not be invoked for this response, but the C will be. +=item response_header => sub { my($response, $ua, $handler) = @_; ... } + +This handler is called right after the response headers have been +received, but before any content data. The handler might set up +handlers for data and might croak to abort the request. + +The handler might set the C<< $response->{default_add_content} >> value to +control if any received data should be added to the response object +directly. This will initially be false if the C<< $ua->request() >> method +was called with a C<$content_file> or C<$content_cb argument>; otherwise true. + +=item response_data => sub { my($response, $ua, $handler, $data) = @_; ... } + +This handler is called for each chunk of data received for the +response. The handler might croak to abort the request. + +This handler needs to return a TRUE value to be called again for +subsequent chunks for the same request. + +=item response_done => sub { my($response, $ua, $handler) = @_; ... } + +The handler is called after the response has been fully received, but +before any redirect handling is attempted. The handler can be used to +extract information or modify the response. + =item response_redirect => sub { my($response, $ua, $handler) = @_; ... } The handler is called in C<< $ua->request >> after C. If the @@ -1988,6 +2033,47 @@ is in the object's C list, false if the proposed redirection is to a C URL, and true otherwise. +=head1 BEST PRACTICES + +The default settings can get you up and running quickly, but there are settings +you can change in order to make your life easier. + +=head2 Handling Cookies + +You are encouraged to install L and use +L as your cookie jar. L provides a +better security model matching that of current Web browsers when +L is installed. + + use HTTP::CookieJar::LWP (); + + my $jar = HTTP::CookieJar::LWP->new; + my $ua = LWP::UserAgent->new( cookie_jar => $jar ); + +See L for more information. + +=head2 Managing Protocols + +C gives you the ability to whitelist the protocols you're +willing to allow. + + my $ua = LWP::UserAgent->new( + protocols_allowed => [ 'http', 'https' ] + ); + +This will prevent you from inadvertently following URLs like +C. See L. + +C gives you the ability to blacklist the protocols you're +unwilling to allow. + + my $ua = LWP::UserAgent->new( + protocols_forbidden => [ 'file', 'mailto', 'ssh', ] + ); + +This can also prevent you from inadvertently following URLs like +C. See L. + =head1 SEE ALSO See L for a complete overview of libwww-perl5. See L diff --git a/t/base/protocols/nntp.t b/t/base/protocols/nntp.t index c53873c..a9b102a 100644 --- a/t/base/protocols/nntp.t +++ b/t/base/protocols/nntp.t @@ -2,7 +2,7 @@ use strict; use warnings; use LWP::UserAgent (); -use Test::More; +use Test::More skip_all => 'nntp.perl.org is unstable and Test::RequiresInternet is not catching it'; use Test::RequiresInternet ( 'nntp.perl.org' => 119 ); plan tests => 1; diff --git a/xt/release/changes_has_content.t b/xt/release/changes_has_content.t index 335f6b8..c0586ee 100644 --- a/xt/release/changes_has_content.t +++ b/xt/release/changes_has_content.t @@ -8,7 +8,7 @@ if (($ENV{TRAVIS_PULL_REQUEST} || '') eq 'false') { note 'Checking Changes'; my $changes_file = 'Changes'; -my $newver = '6.38'; +my $newver = '6.39'; my $trial_token = '-TRIAL'; my $encoding = 'UTF-8'; -- 2.34.1