Imported Upstream version 6.23 upstream/6.23
authorDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 21 Jul 2022 02:28:22 +0000 (11:28 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 21 Jul 2022 02:28:22 +0000 (11:28 +0900)
35 files changed:
Changes
MANIFEST
META.json
META.yml
Makefile.PL
bin/lwp-request
dist.ini
lib/LWP.pm
lib/LWP/Authen/Basic.pm
lib/LWP/Authen/Digest.pm
lib/LWP/Authen/Ntlm.pm
lib/LWP/ConnCache.pm
lib/LWP/Debug.pm
lib/LWP/Debug/TraceHTTP.pm
lib/LWP/DebugFile.pm
lib/LWP/MemberMixin.pm
lib/LWP/Protocol.pm
lib/LWP/Protocol/cpan.pm
lib/LWP/Protocol/data.pm
lib/LWP/Protocol/file.pm
lib/LWP/Protocol/ftp.pm
lib/LWP/Protocol/gopher.pm
lib/LWP/Protocol/http.pm
lib/LWP/Protocol/loopback.pm
lib/LWP/Protocol/mailto.pm
lib/LWP/Protocol/nntp.pm
lib/LWP/Protocol/nogo.pm
lib/LWP/RobotUA.pm
lib/LWP/Simple.pm
lib/LWP/UserAgent.pm
t/base/protocols/nntp.t [new file with mode: 0644]
xt/author/eol.t
xt/author/pod-coverage.t
xt/author/pod-spell.t
xt/release/changes_has_content.t

diff --git a/Changes b/Changes
index 70c35f756bad76dba44b5c6361d800c750f1481a..f093c8ae1c4166eef122592a5815614c02835544 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,11 @@
 Change history for libwww-perl
 
+6.23      2017-03-06
+    - Fix bug where Protocol::NNTP called undef on a variable before being done
+      using it. (GH PR #121)
+    - Ran perltidy on LWP::Protocol::NNTP
+    - Re-organized current documentation set.
+
 6.22      2017-03-01
     - Update Travis-CI to test on minimum versions of prereqs. (GH PR #109)
     - Fix tests that depended on a newer version of HTTP::Message (GH PR #119)
index 7f12eb594877b2c9038e54205e639ee6a30d9c76..a036ddc61e21c191e3f89beb493f0c86a3cf2c27 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -42,6 +42,7 @@ t/00-report-prereqs.dd
 t/00-report-prereqs.t
 t/base/default_content_type.t
 t/base/protocols.t
+t/base/protocols/nntp.t
 t/base/proxy.t
 t/base/simple.t
 t/base/ua.t
index 40d3f1199a0df0465c79d5728672e4b1afa283aa..e86044ae06ce835f4917c542a19521ddca4c041c 100644 (file)
--- a/META.json
+++ b/META.json
    "provides" : {
       "LWP" : {
          "file" : "lib/LWP.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Authen::Basic" : {
          "file" : "lib/LWP/Authen/Basic.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Authen::Digest" : {
          "file" : "lib/LWP/Authen/Digest.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Authen::Ntlm" : {
          "file" : "lib/LWP/Authen/Ntlm.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::ConnCache" : {
          "file" : "lib/LWP/ConnCache.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Debug" : {
          "file" : "lib/LWP/Debug.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Debug::TraceHTTP" : {
          "file" : "lib/LWP/Debug/TraceHTTP.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Debug::TraceHTTP::Socket" : {
          "file" : "lib/LWP/Debug/TraceHTTP.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::DebugFile" : {
          "file" : "lib/LWP/DebugFile.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::MemberMixin" : {
          "file" : "lib/LWP/MemberMixin.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol" : {
          "file" : "lib/LWP/Protocol.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol::MyFTP" : {
          "file" : "lib/LWP/Protocol/ftp.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol::cpan" : {
          "file" : "lib/LWP/Protocol/cpan.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol::data" : {
          "file" : "lib/LWP/Protocol/data.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol::file" : {
          "file" : "lib/LWP/Protocol/file.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol::ftp" : {
          "file" : "lib/LWP/Protocol/ftp.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol::gopher" : {
          "file" : "lib/LWP/Protocol/gopher.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol::http" : {
          "file" : "lib/LWP/Protocol/http.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol::http::Socket" : {
          "file" : "lib/LWP/Protocol/http.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol::http::SocketMethods" : {
          "file" : "lib/LWP/Protocol/http.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol::loopback" : {
          "file" : "lib/LWP/Protocol/loopback.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol::mailto" : {
          "file" : "lib/LWP/Protocol/mailto.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol::nntp" : {
          "file" : "lib/LWP/Protocol/nntp.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Protocol::nogo" : {
          "file" : "lib/LWP/Protocol/nogo.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::RobotUA" : {
          "file" : "lib/LWP/RobotUA.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::Simple" : {
          "file" : "lib/LWP/Simple.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       },
       "LWP::UserAgent" : {
          "file" : "lib/LWP/UserAgent.pm",
-         "version" : "6.22"
+         "version" : "6.23"
       }
    },
    "release_status" : "stable",
       "x_IRC" : "irc://irc.perl.org/#lwp",
       "x_MailingList" : "mailto:libwww@perl.org"
    },
-   "version" : "6.22",
+   "version" : "6.23",
    "x_Dist_Zilla" : {
       "perl" : {
          "version" : "5.024000"
                   "changelog" : "Changes"
                },
                "Dist::Zilla::Role::Git::Repo" : {
-                  "git --version" : "2.11.0",
+                  "git --version" : "2.10.2",
                   "repo_root" : "."
                }
             },
                   "changelog" : "Changes"
                },
                "Dist::Zilla::Role::Git::Repo" : {
-                  "git --version" : "2.11.0",
+                  "git --version" : "2.10.2",
                   "repo_root" : "."
                },
                "Dist::Zilla::Role::Git::StringFormatter" : {
                   "branch" : null,
                   "changelog" : "Changes",
                   "signed" : 0,
-                  "tag" : "v6.22",
+                  "tag" : "v6.23",
                   "tag_format" : "v%v",
                   "tag_message" : "v%v"
                },
                "Dist::Zilla::Role::Git::Repo" : {
-                  "git --version" : "2.11.0",
+                  "git --version" : "2.10.2",
                   "repo_root" : "."
                },
                "Dist::Zilla::Role::Git::StringFormatter" : {
                   "remotes_must_exist" : 1
                },
                "Dist::Zilla::Role::Git::Repo" : {
-                  "git --version" : "2.11.0",
+                  "git --version" : "2.10.2",
                   "repo_root" : "."
                }
             },
             "class" : "Dist::Zilla::Plugin::Git::Contributors",
             "config" : {
                "Dist::Zilla::Plugin::Git::Contributors" : {
-                  "git --version" : "2.11.0",
+                  "git --version" : "2.10.2",
                   "include_authors" : 0,
                   "include_releaser" : 1,
                   "order_by" : "name",
                      "afPuUsSedvhx",
                      "de",
                      "erik",
+                     "getprint",
+                     "getstore",
                      "peterm",
                      "shildreth"
                   ],
index 0de29551d5a600d0bd9febb86cc6b21498d83df8..719d44fa9909d1d08bf292efbc7b7e5f3d99aa74 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -27,85 +27,85 @@ no_index:
 provides:
   LWP:
     file: lib/LWP.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Authen::Basic:
     file: lib/LWP/Authen/Basic.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Authen::Digest:
     file: lib/LWP/Authen/Digest.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Authen::Ntlm:
     file: lib/LWP/Authen/Ntlm.pm
-    version: '6.22'
+    version: '6.23'
   LWP::ConnCache:
     file: lib/LWP/ConnCache.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Debug:
     file: lib/LWP/Debug.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Debug::TraceHTTP:
     file: lib/LWP/Debug/TraceHTTP.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Debug::TraceHTTP::Socket:
     file: lib/LWP/Debug/TraceHTTP.pm
-    version: '6.22'
+    version: '6.23'
   LWP::DebugFile:
     file: lib/LWP/DebugFile.pm
-    version: '6.22'
+    version: '6.23'
   LWP::MemberMixin:
     file: lib/LWP/MemberMixin.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol:
     file: lib/LWP/Protocol.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol::MyFTP:
     file: lib/LWP/Protocol/ftp.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol::cpan:
     file: lib/LWP/Protocol/cpan.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol::data:
     file: lib/LWP/Protocol/data.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol::file:
     file: lib/LWP/Protocol/file.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol::ftp:
     file: lib/LWP/Protocol/ftp.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol::gopher:
     file: lib/LWP/Protocol/gopher.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol::http:
     file: lib/LWP/Protocol/http.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol::http::Socket:
     file: lib/LWP/Protocol/http.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol::http::SocketMethods:
     file: lib/LWP/Protocol/http.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol::loopback:
     file: lib/LWP/Protocol/loopback.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol::mailto:
     file: lib/LWP/Protocol/mailto.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol::nntp:
     file: lib/LWP/Protocol/nntp.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Protocol::nogo:
     file: lib/LWP/Protocol/nogo.pm
-    version: '6.22'
+    version: '6.23'
   LWP::RobotUA:
     file: lib/LWP/RobotUA.pm
-    version: '6.22'
+    version: '6.23'
   LWP::Simple:
     file: lib/LWP/Simple.pm
-    version: '6.22'
+    version: '6.23'
   LWP::UserAgent:
     file: lib/LWP/UserAgent.pm
-    version: '6.22'
+    version: '6.23'
 requires:
   Digest::MD5: '0'
   Encode: '2.12'
@@ -142,7 +142,7 @@ resources:
   bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=libwww-perl
   homepage: https://github.com/libwww-perl/libwww-perl
   repository: https://github.com/libwww-perl/libwww-perl.git
-version: '6.22'
+version: '6.23'
 x_Dist_Zilla:
   perl:
     version: '5.024000'
@@ -222,7 +222,7 @@ x_Dist_Zilla:
           allow_dirty_match: []
           changelog: Changes
         Dist::Zilla::Role::Git::Repo:
-          'git --version': 2.11.0
+          'git --version': 2.10.2
           repo_root: .
       name: '@Git/Check'
       version: '2.041'
@@ -239,7 +239,7 @@ x_Dist_Zilla:
           allow_dirty_match: []
           changelog: Changes
         Dist::Zilla::Role::Git::Repo:
-          'git --version': 2.11.0
+          'git --version': 2.10.2
           repo_root: .
         Dist::Zilla::Role::Git::StringFormatter:
           time_zone: local
@@ -252,11 +252,11 @@ x_Dist_Zilla:
           branch: ~
           changelog: Changes
           signed: 0
-          tag: v6.22
+          tag: v6.23
           tag_format: v%v
           tag_message: v%v
         Dist::Zilla::Role::Git::Repo:
-          'git --version': 2.11.0
+          'git --version': 2.10.2
           repo_root: .
         Dist::Zilla::Role::Git::StringFormatter:
           time_zone: local
@@ -270,7 +270,7 @@ x_Dist_Zilla:
             - origin
           remotes_must_exist: 1
         Dist::Zilla::Role::Git::Repo:
-          'git --version': 2.11.0
+          'git --version': 2.10.2
           repo_root: .
       name: '@Git/Push'
       version: '2.041'
@@ -278,7 +278,7 @@ x_Dist_Zilla:
       class: Dist::Zilla::Plugin::Git::Contributors
       config:
         Dist::Zilla::Plugin::Git::Contributors:
-          'git --version': 2.11.0
+          'git --version': 2.10.2
           include_authors: 0
           include_releaser: 1
           order_by: name
@@ -540,6 +540,8 @@ x_Dist_Zilla:
             - afPuUsSedvhx
             - de
             - erik
+            - getprint
+            - getstore
             - peterm
             - shildreth
           wordlist: Pod::Wordlist
index 1e21c2145c16007bb019c7c804e49f7c7de1bebb..1aac82ec5851e02c527ef2b153b51bbbf881b15c 100644 (file)
@@ -83,9 +83,9 @@ my %WriteMakefileArgs = (
     "Test::More" => 0,
     "Test::RequiresInternet" => 0
   },
-  "VERSION" => "6.22",
+  "VERSION" => "6.23",
   "test" => {
-    "TESTS" => "t/*.t t/base/*.t t/local/*.t t/robot/*.t"
+    "TESTS" => "t/*.t t/base/*.t t/base/protocols/*.t t/local/*.t t/robot/*.t"
   }
 );
 
index cde097273870c62620754ab65d4754cfaaeabc8d..39cbb736ab212fe745270f76e9dd5d46111cc26b 100755 (executable)
@@ -217,7 +217,7 @@ use HTTP::Date qw(time2str str2time);
 # user/password if document is protected.
 {
     package RequestAgent;
-$RequestAgent::VERSION = '6.22';
+$RequestAgent::VERSION = '6.23';
 use base qw(LWP::UserAgent);
 
     sub new
index 920bdb658a3169c3847febd8328367e45ac52dcb..af7a157cb9e15c86913d4e8b0715cac969b5f75b 100644 (file)
--- a/dist.ini
+++ b/dist.ini
@@ -4,7 +4,7 @@ license             = Perl_5
 copyright_holder    = Gisle Aas
 copyright_year      = 1995
 
-version = 6.22
+version = 6.23
 
 ; Gather stuff in
 [Git::GatherDir]
@@ -93,7 +93,7 @@ bail_out_on_fail = 1
 xt_mode = 1
 
 [Test::Portability]
-; TODO perltidy for NoTabs and namespace::autoclean 
+; TODO perltidy for NoTabs and namespace::autoclean
 ; [Test::CleanNamespaces] ; TODO
 ; [Test::NoTabs] ; TODO
 [Test::EOL]
@@ -232,6 +232,8 @@ stopword = Mailto
 stopword = peterm
 stopword = de
 stopword = erik
+stopword = getprint
+stopword = getstore
 
 [RunExtraTests]
 
index 52b38440f88795d58885cbedc93020f20d50d64c..f0825dddca52cfd82aa7d075fb8f072a49da1124 100644 (file)
@@ -1,6 +1,6 @@
 package LWP;
 
-our $VERSION = '6.22';
+our $VERSION = '6.23';
 
 require 5.008;
 require LWP::UserAgent;  # this should load everything you need
index b266563a0b4949bfa229b39743fc33b9ed0d84e2..94f34bb8e6146edacb3e8b04857fdd90dde4268d 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::Authen::Basic;
-$LWP::Authen::Basic::VERSION = '6.22';
+$LWP::Authen::Basic::VERSION = '6.23';
 use strict;
 
 require MIME::Base64;
index 5d9f1231364cdcf32537d036d2efb10e1d677553..977d095b9c1c1693340e791b80cf46d8d6c14022 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::Authen::Digest;
-$LWP::Authen::Digest::VERSION = '6.22';
+$LWP::Authen::Digest::VERSION = '6.23';
 use strict;
 use base 'LWP::Authen::Basic';
 
index 28a2f4d4bd2caab99b3021aa344d5b731144847c..d3896c85e7de74d0291ca54839b9deab7258dc14 100644 (file)
@@ -2,7 +2,7 @@ package LWP::Authen::Ntlm;
 
 use strict;
 
-our $VERSION = '6.22';
+our $VERSION = '6.23';
 
 use Authen::NTLM "1.02";
 use MIME::Base64 "2.12";
index f9be7b177630bce61caa400bb696304439514769..bcb784dd38fc74948ddeefec3f9ba30104ddfb02 100644 (file)
@@ -2,7 +2,7 @@ package LWP::ConnCache;
 
 use strict;
 
-our $VERSION = '6.22';
+our $VERSION = '6.23';
 our $DEBUG;
 
 sub new {
@@ -191,30 +191,56 @@ change in the future.
 The C<LWP::ConnCache> class is the standard connection cache manager
 for L<LWP::UserAgent>.
 
+=head1 METHODS
+
 The following basic methods are provided:
 
-=over
+=head2 new
 
-=item $cache = LWP::ConnCache->new( %options )
+    my $cache = LWP::ConnCache->new( %options )
 
 This method constructs a new L<LWP::ConnCache> object.  The only
-option currently accepted is 'total_capacity'.  If specified it
-initialize the total_capacity option.  It defaults to the value 1.
+option currently accepted is C<total_capacity>.  If specified it
+initialize the L<LWP::ConnCache/total_capacity> option. It defaults to C<1>.
+
+=head2 total_capacity
 
-=item $cache->total_capacity( [$num_connections] )
+    my $cap = $cache->total_capacity;
+    $cache->total_capacity(0); # drop all immediately
+    $cache->total_capacity(undef); # no limit
+    $cache->total_capacity($number);
 
 Get/sets the number of connection that will be cached.  Connections
 will start to be dropped when this limit is reached.  If set to C<0>,
 then all connections are immediately dropped.  If set to C<undef>,
 then there is no limit.
 
-=item $cache->capacity($type, [$num_connections] )
+=head2 capacity
+
+    my $http_capacity = $cache->capacity('http');
+    $cache->capacity('http', 2 );
 
 Get/set a limit for the number of connections of the specified type
-that can be cached.  The $type will typically be a short string like
+that can be cached.  The first parameter is a short string like
 "http" or "ftp".
 
-=item $cache->drop( [$checker, [$reason]] )
+=head2 drop
+
+    $cache->drop(); # Drop ALL connections
+    # which is just a synonym for:
+    $cache->drop(sub{1}); # Drop ALL connections
+    # drop all connections older than 22 seconds and add a reason for it!
+    $cache->drop(22, "Older than 22 secs dropped");
+    # which is just a synonym for:
+    $cache->drop(sub {
+        my ($conn, $type, $key, $deposit_time) = @_;
+        if ($deposit_time < 22) {
+            # true values drop the connection
+            return 1;
+        }
+        # false values don't drop the connection
+        return 0;
+    }, "Older than 22 secs dropped" );
 
 Drop connections by some criteria.  The $checker argument is a
 subroutine that is called for each connection.  If the routine returns
@@ -227,41 +253,49 @@ connections untouched that the given number of seconds or more are
 dropped.  If $checker is a string then all connections of the given
 type are dropped.
 
-The $reason argument is passed on to the dropped() method.
+The C<reason> is passed on to the L<LWP::ConnCache/dropped> method.
 
-=item $cache->prune
+=head2 prune
+
+    $cache->prune();
 
 Calling this method will drop all connections that are dead.  This is
-tested by calling the ping() method on the connections.  If the ping()
-method exists and returns a FALSE value, then the connection is
-dropped.
+tested by calling the L<LWP::ConnCache/ping> method on the connections. If
+the L<LWP::ConnCache/ping> method exists and returns a false value, then the
+connection is dropped.
+
+=head2 get_types
 
-=item $cache->get_types
+    my @types = $cache->get_types();
 
-This returns all the 'type' fields used for the currently cached
+This returns all the C<type> fields used for the currently cached
 connections.
 
-=item $cache->get_connections( [$type] )
+=head2 get_connections
+
+    my @conns = $cache->get_connections(); # all connections
+    my @conns = $cache->get_connections('http'); # connections for http
 
 This returns all connection objects of the specified type.  If no type
 is specified then all connections are returned.  In scalar context the
 number of cached connections of the specified type is returned.
 
-=back
-
+=head1 PROTOCOL METHODS
 
 The following methods are called by low-level protocol modules to
 try to save away connections and to get them back.
 
-=over
+=head2 deposit
 
-=item $cache->deposit($type, $key, $conn)
+    $cache->deposit($type, $key, $conn);
 
-This method adds a new connection to the cache.  As a result other
+This method adds a new connection to the cache.  As a result, other
 already cached connections might be dropped.  Multiple connections with
-the same $type/$key might added.
+the same type/key might be added.
+
+=head2 withdraw
 
-=item $conn = $cache->withdraw($type, $key)
+    my $conn = $cache->withdraw($type, $key);
 
 This method tries to fetch back a connection that was previously
 deposited.  If no cached connection with the specified $type/$key is
@@ -269,35 +303,35 @@ found, then C<undef> is returned.  There is not guarantee that a
 deposited connection can be withdrawn, as the cache manger is free to
 drop connections at any time.
 
-=back
+=head1 INTERNAL METHODS
 
 The following methods are called internally.  Subclasses might want to
 override them.
 
-=over
+=head2 enforce_limits
 
-=item $conn->enforce_limits([$type])
+    $conn->enforce_limits([$type])
 
 This method is called with after a new connection is added (deposited)
 in the cache or capacity limits are adjusted.  The default
 implementation drops connections until the specified capacity limits
 are not exceeded.
 
-=item $conn->dropping($conn_record, $reason)
+=head2 dropping
+
+    $conn->dropping($conn_record, $reason)
 
 This method is called when a connection is dropped.  The record
 belonging to the dropped connection is passed as the first argument
 and a string describing the reason for the drop is passed as the
 second argument.  The default implementation makes some noise if the
-$LWP::ConnCache::DEBUG variable is set and nothing more.
-
-=back
+C<$LWP::ConnCache::DEBUG> variable is set and nothing more.
 
 =head1 SUBCLASSING
 
 For specialized cache policy it makes sense to subclass
-C<LWP::ConnCache> and perhaps override the deposit(), enforce_limits()
-and dropping() methods.
+C<LWP::ConnCache> and perhaps override the L<LWP::ConnCache/deposit>,
+L<LWP::ConnCache/enforce_limits>, and L<LWP::ConnCache/dropping> methods.
 
 The object itself is a hash.  Keys prefixed with C<cc_> are reserved
 for the base class.
index d059b2b30756ddcb663fe48ea18f32edacb12a32..a179f063881157763daebacbbbe6e5e6fabfa7f4 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::Debug;    # legacy
-$LWP::Debug::VERSION = '6.22';
+$LWP::Debug::VERSION = '6.23';
 require Exporter;
 our @ISA       = qw(Exporter);
 our @EXPORT_OK = qw(level trace debug conns);
index 57ef84abd706fc6c7c4515a460431839f865f3a1..6625a3eec27c5dafa51d6d9b1720ad8e39c7b7e8 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::Debug::TraceHTTP;
-$LWP::Debug::TraceHTTP::VERSION = '6.22';
+$LWP::Debug::TraceHTTP::VERSION = '6.23';
 # Just call:
 #
 #   require LWP::Debug::TraceHTTP;
@@ -12,7 +12,7 @@ use strict;
 use base 'LWP::Protocol::http';
 
 package LWP::Debug::TraceHTTP::Socket;
-$LWP::Debug::TraceHTTP::Socket::VERSION = '6.22';
+$LWP::Debug::TraceHTTP::Socket::VERSION = '6.23';
 use Data::Dump 1.13;
 use Data::Dump::Trace qw(autowrap mcall);
 
index 66c8a7ac326e0a1b0baa272c53445dfd363776e6..2cde34e13a1119608bd6dbec2cf80286e7436919 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::DebugFile;
-$LWP::DebugFile::VERSION = '6.22';
+$LWP::DebugFile::VERSION = '6.23';
 # legacy stub
 
 1;
index 32e679573f5c107e0b68da81b43fd79c7386430b..0a3aee50df8bd47693c024f45dbf2925d8008cd2 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::MemberMixin;
-$LWP::MemberMixin::VERSION = '6.22';
+$LWP::MemberMixin::VERSION = '6.23';
 sub _elem {
     my $self = shift;
     my $elem = shift;
@@ -21,8 +21,7 @@ LWP::MemberMixin - Member access mixin class
 =head1 SYNOPSIS
 
  package Foo;
- require LWP::MemberMixin;
- @ISA=qw(LWP::MemberMixin);
+ use base qw(LWP::MemberMixin);
 
 =head1 DESCRIPTION
 
@@ -30,11 +29,13 @@ A mixin class to get methods that provide easy access to member
 variables in the C<%$self>.
 Ideally there should be better Perl language support for this.
 
+=head1 METHODS
+
 There is only one method provided:
 
-=over 4
+=head2 _elem
 
-=item _elem($elem [, $val])
+    _elem($elem [, $val])
 
 Internal method to get/set the value of member variable
 C<$elem>. If C<$val> is present it is used as the new value
@@ -42,6 +43,4 @@ for the member variable.  If it is not present the current
 value is not touched. In both cases the previous value of
 the member variable is returned.
 
-=back
-
 =cut
index 076855edcce01d2da6b0e6598178c264cc54af9b..1661e7c3ee5fc8547238ba2b67da5fbcf550f83a 100644 (file)
@@ -2,7 +2,7 @@ package LWP::Protocol;
 
 use base 'LWP::MemberMixin';
 
-our $VERSION = '6.22';
+our $VERSION = '6.23';
 
 use strict;
 use Carp ();
@@ -202,8 +202,7 @@ LWP::Protocol - Base class for LWP protocols
 =head1 SYNOPSIS
 
  package LWP::Protocol::foo;
- require LWP::Protocol;
- @ISA=qw(LWP::Protocol);
+ use base qw(LWP::Protocol);
 
 =head1 DESCRIPTION
 
@@ -213,7 +212,7 @@ supported by the LWP library.
 When creating an instance of this class using
 C<LWP::Protocol::create($url)>, and you get an initialized subclass
 appropriate for that access method. In other words, the
-LWP::Protocol::create() function calls the constructor for one of its
+L<LWP::Protocol/create> function calls the constructor for one of its
 subclasses.
 
 All derived C<LWP::Protocol> classes need to override the request()
@@ -221,66 +220,75 @@ method which is used to service a request. The overridden method can
 make use of the collect() function to collect together chunks of data
 as it is received.
 
+=head1 METHODS
+
 The following methods and functions are provided:
 
-=over 4
+=head2 new
 
-=item $prot = LWP::Protocol->new()
+    my $prot = LWP::Protocol->new();
 
 The LWP::Protocol constructor is inherited by subclasses. As this is a
 virtual base class this method should B<not> be called directly.
 
-=item $prot = LWP::Protocol::create($scheme)
+=head2 create
+
+    my $prot = LWP::Protocol::create($scheme)
 
 Create an object of the class implementing the protocol to handle the
 given scheme. This is a function, not a method. It is more an object
 factory than a constructor. This is the function user agents should
 use to access protocols.
 
-=item $class = LWP::Protocol::implementor($scheme, [$class])
+=head2 implementor
+
+    my $class = LWP::Protocol::implementor($scheme, [$class])
 
-Get and/or set implementor class for a scheme.  Returns '' if the
+Get and/or set implementor class for a scheme.  Returns C<''> if the
 specified scheme is not supported.
 
-=item $prot->request(...)
+=head2 request
 
- $response = $protocol->request($request, $proxy, undef);
- $response = $protocol->request($request, $proxy, '/tmp/sss');
- $response = $protocol->request($request, $proxy, \&callback, 1024);
   $response = $protocol->request($request, $proxy, undef);
   $response = $protocol->request($request, $proxy, '/tmp/sss');
   $response = $protocol->request($request, $proxy, \&callback, 1024);
 
 Dispatches a request over the protocol, and returns a response
 object. This method needs to be overridden in subclasses.  Refer to
 L<LWP::UserAgent> for description of the arguments.
 
-=item $prot->collect($arg, $response, $collector)
+=head2 collect
 
-Called to collect the content of a request, and process it
-appropriately into a scalar, file, or by calling a callback.  If $arg
-is undefined, then the content is stored within the $response.  If
-$arg is a simple scalar, then $arg is interpreted as a file name and
-the content is written to this file.  If $arg is a reference to a
-routine, then content is passed to this routine.
+    my $res = $prot->collect(undef, $response, $collector); # stored in $response
+    my $res = $prot->collect($filename, $response, $collector);
+    my $res = $prot->collect(sub { ... }, $response, $collector);
 
-The $collector is a routine that will be called and which is
+Collect the content of a request, and process it appropriately into a scalar,
+file, or by calling a callback. If the first parameter is undefined, then the
+content is stored within the C<$response>. If it's a simple scalar, then it's
+interpreted as a file name and the content is written to this file.  If it's a
+code reference, then content is passed to this routine.
+
+The collector is a routine that will be called and which is
 responsible for returning pieces (as ref to scalar) of the content to
-process.  The $collector signals EOF by returning a reference to an
+process.  The C<$collector> signals C<EOF> by returning a reference to an
 empty string.
 
-The return value from collect() is the $response object reference.
+The return value is the L<HTTP::Response> object reference.
 
 B<Note:> We will only use the callback or file argument if
-$response->is_success().  This avoids sending content data for
+C<< $response->is_success() >>.  This avoids sending content data for
 redirects and authentication responses to the callback which would be
 confusing.
 
-=item $prot->collect_once($arg, $response, $content)
+=head2 collect_once
 
-Can be called when the whole response content is available as
-$content.  This will invoke collect() with a collector callback that
-returns a reference to $content the first time and an empty string the
-next.
+    $prot->collect_once($arg, $response, $content)
 
-=back
+Can be called when the whole response content is available as content. This
+will invoke L<LWP::Protocol/collect> with a collector callback that
+returns a reference to C<$content> the first time and an empty string the
+next.
 
 =head1 SEE ALSO
 
index c39dc4fd4ebe1793b733661db048628a2207e0e5..767da9d8c0b23d7ec73f7579a419d368e8f63df3 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::Protocol::cpan;
-$LWP::Protocol::cpan::VERSION = '6.22';
+$LWP::Protocol::cpan::VERSION = '6.23';
 use strict;
 
 use base qw(LWP::Protocol);
index bd555115be59f7a2a807f703ddb46255ad470537..9dbd5f0b87a4f3edc7162470834a147b642cdd4d 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::Protocol::data;
-$LWP::Protocol::data::VERSION = '6.22';
+$LWP::Protocol::data::VERSION = '6.23';
 # Implements access to data:-URLs as specified in RFC 2397
 
 use strict;
index b6740769f526865c1768560227afe8f210b74e42..e7c4fec773ec3b7594b1a043446acc8c80185d73 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::Protocol::file;
-$LWP::Protocol::file::VERSION = '6.22';
+$LWP::Protocol::file::VERSION = '6.23';
 use base qw(LWP::Protocol);
 
 use strict;
index c4d4af196b76708cd489fd9646e1dcd45219c482..71f64334fbb419eeff855af4557297a403686697 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::Protocol::ftp;
-$LWP::Protocol::ftp::VERSION = '6.22';
+$LWP::Protocol::ftp::VERSION = '6.23';
 # Implementation of the ftp protocol (RFC 959). We let the Net::FTP
 # package do all the dirty work.
 
@@ -16,7 +16,7 @@ use base qw(LWP::Protocol);
 use strict;
 eval {
     package LWP::Protocol::MyFTP;
-$LWP::Protocol::MyFTP::VERSION = '6.22';
+$LWP::Protocol::MyFTP::VERSION = '6.23';
 require Net::FTP;
     Net::FTP->require_version(2.00);
 
index 18a4433bf1fe52640b7b910ef49705cdc280e24d..ad70273db5cdd16ee63059eefd23686770466039 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::Protocol::gopher;
-$LWP::Protocol::gopher::VERSION = '6.22';
+$LWP::Protocol::gopher::VERSION = '6.23';
 # Implementation of the gopher protocol (RFC 1436)
 #
 # This code is based on 'wwwgopher.pl,v 0.10 1994/10/17 18:12:34 shelden'
index 4c45279a6538d2648f12f53fb57a48e6d77aabdf..6911cae44cd91054ed3cbb0771f847d09e4805e3 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::Protocol::http;
-$LWP::Protocol::http::VERSION = '6.22';
+$LWP::Protocol::http::VERSION = '6.23';
 use strict;
 
 require HTTP::Response;
@@ -498,7 +498,7 @@ sub request
 
 #-----------------------------------------------------------
 package LWP::Protocol::http::SocketMethods;
-$LWP::Protocol::http::SocketMethods::VERSION = '6.22';
+$LWP::Protocol::http::SocketMethods::VERSION = '6.23';
 sub ping {
     my $self = shift;
     !$self->can_read(0);
@@ -511,7 +511,7 @@ sub increment_response_count {
 
 #-----------------------------------------------------------
 package LWP::Protocol::http::Socket;
-$LWP::Protocol::http::Socket::VERSION = '6.22';
+$LWP::Protocol::http::Socket::VERSION = '6.23';
 use base qw(LWP::Protocol::http::SocketMethods Net::HTTP);
 
 1;
index a0e424211118590ca9e85cb62f108bceb6092dc0..41d11b89eb9cf91998db9a1ba3f916c8f93ff725 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::Protocol::loopback;
-$LWP::Protocol::loopback::VERSION = '6.22';
+$LWP::Protocol::loopback::VERSION = '6.23';
 use strict;
 require HTTP::Response;
 
index 99aa455e6653b62ec493e9bb181aad208f3e1488..20560e6694b5738d1c6f8f10c11d80b878e2676c 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::Protocol::mailto;
-$LWP::Protocol::mailto::VERSION = '6.22';
+$LWP::Protocol::mailto::VERSION = '6.23';
 # This module implements the mailto protocol.  It is just a simple
 # frontend to the Unix sendmail program except on MacOS, where it uses
 # Mail::Internet.
index 5a81d4d4955ae165b231b3cba200a06c59387296..85f7fb5bfb6689a1e498db41d37dd02f05c1e2ac 100644 (file)
@@ -1,5 +1,5 @@
 package LWP::Protocol::nntp;
-$LWP::Protocol::nntp::VERSION = '6.22';
+$LWP::Protocol::nntp::VERSION = '6.23';
 # Implementation of the Network News Transfer Protocol (RFC 977)
 
 use base qw(LWP::Protocol);
@@ -11,54 +11,55 @@ require Net::NNTP;
 use strict;
 
 
-sub request
-{
-    my($self, $request, $proxy, $arg, $size, $timeout) = @_;
+sub request {
+    my ($self, $request, $proxy, $arg, $size, $timeout) = @_;
 
     $size = 4096 unless $size;
 
     # Check for proxy
     if (defined $proxy) {
-       return HTTP::Response->new(HTTP::Status::RC_BAD_REQUEST,
-                                  'You can not proxy through NNTP');
+        return HTTP::Response->new(HTTP::Status::RC_BAD_REQUEST,
+            'You can not proxy through NNTP');
     }
 
     # Check that the scheme is as expected
-    my $url = $request->uri;
+    my $url    = $request->uri;
     my $scheme = $url->scheme;
     unless ($scheme eq 'news' || $scheme eq 'nntp') {
-       return HTTP::Response->new(HTTP::Status::RC_INTERNAL_SERVER_ERROR,
-                                  "LWP::Protocol::nntp::request called for '$scheme'");
+        return HTTP::Response->new(HTTP::Status::RC_INTERNAL_SERVER_ERROR,
+            "LWP::Protocol::nntp::request called for '$scheme'");
     }
 
     # check for a valid method
     my $method = $request->method;
     unless ($method eq 'GET' || $method eq 'HEAD' || $method eq 'POST') {
-       return HTTP::Response->new(HTTP::Status::RC_BAD_REQUEST,
-                                  'Library does not allow method ' .
-                                  "$method for '$scheme:' URLs");
+        return HTTP::Response->new(HTTP::Status::RC_BAD_REQUEST,
+            'Library does not allow method ' . "$method for '$scheme:' URLs");
     }
 
     # extract the identifier and check against posting to an article
     my $groupart = $url->_group;
-    my $is_art = $groupart =~ /@/;
+    my $is_art   = $groupart =~ /@/;
 
     if ($is_art && $method eq 'POST') {
-       return HTTP::Response->new(HTTP::Status::RC_BAD_REQUEST,
-                                  "Can't post to an article <$groupart>");
+        return HTTP::Response->new(HTTP::Status::RC_BAD_REQUEST,
+            "Can't post to an article <$groupart>");
     }
 
-    my $nntp = Net::NNTP->new($url->host,
-                             #Port    => 18574,
-                             Timeout => $timeout,
-                             #Debug   => 1,
-                            );
+    my $nntp = Net::NNTP->new(
+        $url->host,
+
+        #Port    => 18574,
+        Timeout => $timeout,
+
+        #Debug   => 1,
+    );
     die "Can't connect to nntp server" unless $nntp;
 
     # Check the initial welcome message from the NNTP server
     if ($nntp->status != 2) {
-       return HTTP::Response->new(HTTP::Status::RC_SERVICE_UNAVAILABLE,
-                                  $nntp->message);
+        return HTTP::Response->new(HTTP::Status::RC_SERVICE_UNAVAILABLE,
+            $nntp->message);
     }
     my $response = HTTP::Response->new(HTTP::Status::RC_OK, "OK");
 
@@ -73,66 +74,69 @@ sub request
 
     # First we handle posting of articles
     if ($method eq 'POST') {
-       $nntp->quit; $nntp = undef;
-       $response->code(HTTP::Status::RC_NOT_IMPLEMENTED);
-       $response->message("POST not implemented yet");
-       return $response;
+        $nntp->quit;
+        $nntp = undef;
+        $response->code(HTTP::Status::RC_NOT_IMPLEMENTED);
+        $response->message("POST not implemented yet");
+        return $response;
     }
 
     # The method must be "GET" or "HEAD" by now
     if (!$is_art) {
-       if (!$nntp->group($groupart)) {
-           $response->code(HTTP::Status::RC_NOT_FOUND);
-           $response->message($nntp->message);
-       }
-       $nntp->quit; $nntp = undef;
-       # HEAD: just check if the group exists
-       if ($method eq 'GET' && $response->is_success) {
-           $response->code(HTTP::Status::RC_NOT_IMPLEMENTED);
-           $response->message("GET newsgroup not implemented yet");
-       }
-       return $response;
+        if (!$nntp->group($groupart)) {
+            $response->code(HTTP::Status::RC_NOT_FOUND);
+            $response->message($nntp->message);
+        }
+        $nntp->quit;
+        $nntp = undef;
+
+        # HEAD: just check if the group exists
+        if ($method eq 'GET' && $response->is_success) {
+            $response->code(HTTP::Status::RC_NOT_IMPLEMENTED);
+            $response->message("GET newsgroup not implemented yet");
+        }
+        return $response;
     }
 
     # Send command to server to retrieve an article (or just the headers)
     my $get = $method eq 'HEAD' ? "head" : "article";
     my $art = $nntp->$get("<$groupart>");
     unless ($art) {
-       $nntp->quit; $nntp = undef;
-       $response->code(HTTP::Status::RC_NOT_FOUND);
-       $response->message($nntp->message);
-       return $response;
+        $nntp->quit;
+        $response->code(HTTP::Status::RC_NOT_FOUND);
+        $response->message($nntp->message);
+        $nntp = undef;
+        return $response;
     }
 
     # Parse headers
-    my($key, $val);
+    my ($key, $val);
     local $_;
     while ($_ = shift @$art) {
-       if (/^\s+$/) {
-           last;  # end of headers
-       }
-       elsif (/^(\S+):\s*(.*)/) {
-           $response->push_header($key, $val) if $key;
-           ($key, $val) = ($1, $2);
-       }
-       elsif (/^\s+(.*)/) {
-           next unless $key;
-           $val .= $1;
-       }
-       else {
-           unshift(@$art, $_);
-           last;
-       }
+        if (/^\s+$/) {
+            last;    # end of headers
+        }
+        elsif (/^(\S+):\s*(.*)/) {
+            $response->push_header($key, $val) if $key;
+            ($key, $val) = ($1, $2);
+        }
+        elsif (/^\s+(.*)/) {
+            next unless $key;
+            $val .= $1;
+        }
+        else {
+            unshift(@$art, $_);
+            last;
+        }
     }
     $response->push_header($key, $val) if $key;
 
     # Ensure that there is a Content-Type header
     $response->header("Content-Type", "text/plain")
-       unless $response->header("Content-Type");
+        unless $response->header("Content-Type");
 
     # Collect the body
-    $response = $self->collect_once($arg, $response, join("", @$art))
-      if @$art;
+    $response = $self->collect_once($arg, $response, join("", @$art)) if @$art;
 
     # Say goodbye to the server
     $nntp->quit;
index 0590e9ca8e539340eb782a0c9a5bc8ac3e0b326b..508ffb9f26f0d32192e0aa9d113be10e19ba552e 100644 (file)
@@ -4,7 +4,7 @@ package LWP::Protocol::nogo;
 #   LWP::Protocol::implementor(that_scheme, 'LWP::Protocol::nogo');
 # For then on, attempts to access URLs with that scheme will generate
 # a 500 error.
-$LWP::Protocol::nogo::VERSION = '6.22';
+$LWP::Protocol::nogo::VERSION = '6.23';
 use strict;
 
 require HTTP::Response;
index 5deb6b2226a494bf57ea92d01604da43c8df2a1e..e57c0cdac973da565cac7bf9eac76cc63b94a928 100644 (file)
@@ -2,7 +2,7 @@ package LWP::RobotUA;
 
 use base qw(LWP::UserAgent);
 
-our $VERSION = '6.22';
+our $VERSION = '6.23';
 
 require WWW::RobotRules;
 require HTTP::Request;
@@ -215,7 +215,7 @@ should consult the F</robots.txt> file to ensure that they are welcomed
 and they should not make requests too frequently.
 
 But before you consider writing a robot, take a look at
-<URL:http://www.robotstxt.org/>.
+L<URL:http://www.robotstxt.org/>.
 
 When you use an I<LWP::RobotUA> object as your user agent, then you do not
 really have to think about these things yourself; C<robots.txt> files
@@ -228,16 +228,14 @@ special agent will make sure you are nice.
 
 =head1 METHODS
 
-The LWP::RobotUA is a sub-class of LWP::UserAgent and implements the
+The LWP::RobotUA is a sub-class of L<LWP::UserAgent> and implements the
 same methods. In addition the following methods are provided:
 
-=over 4
+=head2 new
 
-=item $ua = LWP::RobotUA->new( %options )
-
-=item $ua = LWP::RobotUA->new( $agent, $from )
-
-=item $ua = LWP::RobotUA->new( $agent, $from, $rules )
+    my $ua = LWP::RobotUA->new( %options )
+    my $ua = LWP::RobotUA->new( $agent, $from )
+    my $ua = LWP::RobotUA->new( $agent, $from, $rules )
 
 The LWP::UserAgent options C<agent> and C<from> are mandatory.  The
 options C<delay>, C<use_sleep> and C<rules> initialize attributes
@@ -248,51 +246,58 @@ F<robots.txt>.
 It is also possible to just pass the value of C<agent>, C<from> and
 optionally C<rules> as plain positional arguments.
 
-=item $ua->delay
+=head2 delay
 
-=item $ua->delay( $minutes )
+    my $delay = $ua->delay;
+    $ua->delay( $minutes );
 
 Get/set the minimum delay between requests to the same server, in
-I<minutes>.  The default is 1 minute.  Note that this number doesn't
-have to be an integer; for example, this sets the delay to 10 seconds:
+I<minutes>.  The default is C<1> minute.  Note that this number doesn't
+have to be an integer; for example, this sets the delay to C<10> seconds:
 
     $ua->delay(10/60);
 
-=item $ua->use_sleep
+=head2 use_sleep
 
-=item $ua->use_sleep( $boolean )
+    my $bool = $ua->use_sleep;
+    $ua->use_sleep( $boolean );
 
-Get/set a value indicating whether the UA should sleep() if requests
-arrive too fast, defined as $ua->delay minutes not passed since
-last request to the given server.  The default is TRUE.  If this value is
-FALSE then an internal SERVICE_UNAVAILABLE response will be generated.
-It will have a Retry-After header that indicates when it is OK to
+Get/set a value indicating whether the UA should L<LWP::RobotUA/sleep> if
+requests arrive too fast, defined as C<< $ua->delay >> minutes not passed since
+last request to the given server.  The default is true.  If this value is
+false then an internal C<SERVICE_UNAVAILABLE> response will be generated.
+It will have a C<Retry-After> header that indicates when it is OK to
 send another request to this server.
 
-=item $ua->rules
+=head2 rules
 
-=item $ua->rules( $rules )
+    my $rules = $ua->rules;
+    $ua->rules( $rules );
 
 Set/get which I<WWW::RobotRules> object to use.
 
-=item $ua->no_visits( $netloc )
+=head2 no_visits
+
+    my $num = $ua->no_visits( $netloc )
 
 Returns the number of documents fetched from this server host. Yeah I
-know, this method should probably have been named num_visits() or
+know, this method should probably have been named C<num_visits> or
 something like that. :-(
 
-=item $ua->host_wait( $netloc )
+=head2 host_wait
+
+    my $num = $ua->host_wait( $netloc )
 
 Returns the number of I<seconds> (from now) you must wait before you can
 make a new request to this host.
 
-=item $ua->as_string
+=head2 as_string
+
+    my $string = $ua->as_string;
 
 Returns a string that describes the state of the UA.
 Mainly useful for debugging.
 
-=back
-
 =head1 SEE ALSO
 
 L<LWP::UserAgent>, L<WWW::RobotRules>
index 8176dbb0f0b380523fe6a51e6a28c162ce0c9d91..7a14b45e129f2bbb38227565e2524562589fa390 100644 (file)
@@ -2,7 +2,7 @@ package LWP::Simple;
 
 use strict;
 
-our $VERSION = '6.22';
+our $VERSION = '6.23';
 
 require Exporter;
 
@@ -125,22 +125,34 @@ you need more control or access to the header fields in the requests
 sent and responses received, then you should use the full object-oriented
 interface provided by the L<LWP::UserAgent> module.
 
+The module will also export the L<LWP::UserAgent> object as C<$ua> if you
+ask for it explicitly.
+
+The user agent created by this module will identify itself as
+C<LWP::Simple/#.##>
+and will initialize its proxy defaults from the environment (by
+calling C<< $ua->env_proxy >>).
+
+=head1 FUNCTIONS
+
 The following functions are provided (and exported) by this module:
 
-=over 3
+=head2 get
 
-=item get($url)
+    my $res = get($url);
 
 The get() function will fetch the document identified by the given URL
-and return it.  It returns C<undef> if it fails.  The $url argument can
-be either a string or a reference to a URI object.
+and return it.  It returns C<undef> if it fails.  The C<$url> argument can
+be either a string or a reference to a L<URI> object.
 
 You will not be able to examine the response code or response headers
-(like 'Content-Type') when you are accessing the web using this
+(like C<Content-Type>) when you are accessing the web using this
 function.  If you need that information you should use the full OO
 interface (see L<LWP::UserAgent>).
 
-=item head($url)
+=head2 head
+
+    my $res = head($url);
 
 Get document headers. Returns the following 5 values if successful:
 ($content_type, $document_length, $modified_time, $expires, $server)
@@ -148,7 +160,9 @@ Get document headers. Returns the following 5 values if successful:
 Returns an empty list if it fails.  In scalar context returns TRUE if
 successful.
 
-=item getprint($url)
+=head2 getprint
+
+    my $code = getprint($url);
 
 Get and print a document identified by a URL. The document is printed
 to the selected default filehandle for output (normally STDOUT) as
@@ -156,22 +170,26 @@ data is received from the network.  If the request fails, then the
 status code and message are printed on STDERR.  The return value is
 the HTTP response code.
 
-=item getstore($url, $file)
+=head2 getstore
+
+    my $code = getstore($url, $file)
 
 Gets a document identified by a URL and stores it in the file. The
 return value is the HTTP response code.
 
-=item mirror($url, $file)
+=head2 mirror
+
+    my $code = mirror($url, $file);
 
 Get and store a document identified by a URL, using
 I<If-modified-since>, and checking the I<Content-Length>.  Returns
 the HTTP response code.
 
-=back
+=head1 STATUS CONSTANTS
 
-This module also exports the HTTP::Status constants and procedures.
-You can use them when you check the response code from getprint(),
-getstore() or mirror().  The constants are:
+This module also exports the L<HTTP::Status> constants and procedures.
+You can use them when you check the response code from L<LWP::Simple/getprint>,
+L<LWP::Simple/getstore> or L<LWP::Simple/mirror>.  The constants are:
 
    RC_CONTINUE
    RC_SWITCHING_PROTOCOLS
@@ -211,34 +229,28 @@ getstore() or mirror().  The constants are:
    RC_GATEWAY_TIMEOUT
    RC_HTTP_VERSION_NOT_SUPPORTED
 
-The HTTP::Status classification functions are:
+=head1 CLASSIFICATION FUNCTIONS
+
+The L<HTTP::Status> classification functions are:
 
-=over 3
+=head2 is_success
 
-=item is_success($rc)
+    my $bool = is_success($rc);
 
 True if response code indicated a successful request.
 
-=item is_error($rc)
+=head2 is_error
 
-True if response code indicated that an error occurred.
+    my $bool = is_error($rc)
 
-=back
-
-The module will also export the LWP::UserAgent object as C<$ua> if you
-ask for it explicitly.
-
-The user agent created by this module will identify itself as
-"LWP::Simple/#.##"
-and will initialize its proxy defaults from the environment (by
-calling $ua->env_proxy).
+True if response code indicated that an error occurred.
 
 =head1 CAVEAT
 
-Note that if you are using both LWP::Simple and the very popular CGI.pm
+Note that if you are using both LWP::Simple and the very popular L<CGI>
 module, you may be importing a C<head> function from each module,
-producing a warning like "Prototype mismatch: sub main::head ($) vs
-none". Get around this problem by just not importing LWP::Simple's
+producing a warning like C<Prototype mismatch: sub main::head ($) vs none>.
+Get around this problem by just not importing LWP::Simple's
 C<head> function, like so:
 
         use LWP::Simple qw(!head);
index f15b855194328e29b1d4ebe5984b8eaddd2eec95..6cbf2f18375b00224379abf6ddfadaf19109bd32 100644 (file)
@@ -15,7 +15,7 @@ use LWP::Protocol ();
 use Scalar::Util qw(blessed);
 use Try::Tiny qw(try catch);
 
-our $VERSION = '6.22';
+our $VERSION = '6.23';
 
 sub new
 {
@@ -1113,7 +1113,9 @@ LWP::UserAgent - Web user agent class
 
 =head1 SYNOPSIS
 
- require LWP::UserAgent;
+ use strict;
+ use warnings;
+ use LWP::UserAgent ();
 
  my $ua = LWP::UserAgent->new;
  $ua->timeout(10);
@@ -1139,24 +1141,32 @@ then creates an instance of L<HTTP::Request> for the request that
 needs to be performed. This request is then passed to one of the
 request method the UserAgent, which dispatches it using the relevant
 protocol, and returns a L<HTTP::Response> object.  There are
-convenience methods for sending the most common request types: get(),
-head(), post(), put() and delete().  When using these methods then the
-creation of the request object is hidden as shown in the synopsis above.
+convenience methods for sending the most common request types:
+L<LWP::UserAgent/get>, L<LWP::UserAgent/head>, L<LWP::UserAgent/post>,
+L<LWP::UserAgent/put> and L<LWP::UserAgent/delete>.  When using these
+methods, the creation of the request object is hidden as shown in the
+synopsis above.
 
-The basic approach of the library is to use HTTP style communication
+The basic approach of the library is to use HTTP-style communication
 for all protocol schemes.  This means that you will construct
 L<HTTP::Request> objects and receive L<HTTP::Response> objects even
 for non-HTTP resources like I<gopher> and I<ftp>.  In order to achieve
-even more similarity to HTTP style communications, gopher menus and
+even more similarity to HTTP-style communications, I<gopher> menus and
 file directories are converted to HTML documents.
 
 =head1 CONSTRUCTOR METHODS
 
 The following constructor methods are available:
 
-=over 4
+=head2 clone
 
-=item $ua = LWP::UserAgent->new( %options )
+    my $ua2 = $ua->clone;
+
+Returns a copy of the L<LWP::UserAgent> object.
+
+=head2 new
+
+    my $ua = LWP::UserAgent->new( %options )
 
 This method constructs a new L<LWP::UserAgent> object and returns it.
 Key/value pair arguments may be provided to set up the initial state.
@@ -1170,7 +1180,7 @@ The following options correspond to attribute methods described below:
    cookie_jar              undef
    default_headers         HTTP::Headers->new
    local_address           undef
-   ssl_opts               { verify_hostname => 1 }
+   ssl_opts                { verify_hostname => 1 }
    max_size                undef
    max_redirect            7
    parse_head              1
@@ -1180,18 +1190,13 @@ The following options correspond to attribute methods described below:
    timeout                 180
 
 The following additional options are also accepted: If the C<env_proxy> option
-is passed in with a TRUE value, then proxy settings are read from environment
-variables (see env_proxy() method below).  If C<env_proxy> isn't provided the
-C<PERL_LWP_ENV_PROXY> environment variable controls if env_proxy() is called
-during initialization.  If the C<keep_alive> option is passed in, then a
-C<LWP::ConnCache> is set up (see conn_cache() method below).  The C<keep_alive>
-value is passed on as the C<total_capacity> for the connection cache.
-
-=item $ua->clone
-
-Returns a copy of the LWP::UserAgent object.
-
-=back
+is passed in with a true value, then proxy settings are read from environment
+variables (see L<LWP::UserAgent/env_proxy>). If C<env_proxy> isn't provided, the
+C<PERL_LWP_ENV_PROXY> environment variable controls if
+L<LWP::UserAgent/env_proxy> is called during initialization.  If the
+C<keep_alive> option is passed in, then a C<LWP::ConnCache> is set up (see
+L<LWP::UserAgent/conn_cache>).  The C<keep_alive> value is passed on as the
+C<total_capacity> for the connection cache.
 
 =head1 ATTRIBUTES
 
@@ -1203,67 +1208,52 @@ The following attribute methods are provided.  The attribute value is
 left unchanged if no argument is given.  The return value from each
 method is the old attribute value.
 
-=over
-
-=item $ua->agent
+=head2 agent
 
-=item $ua->agent( $product_id )
+    my $agent = $ua->agent;
+    $ua->agent('Checkbot/0.4 ');    # append the defaul to the end
+    $ua->agent('Mozilla/5.0');
+    $ua->agent("");                 # don't identify
 
 Get/set the product token that is used to identify the user agent on
-the network.  The agent value is sent as the "User-Agent" header in
-the requests.  The default is the string returned by the _agent()
-method (see below).
+the network. The agent value is sent as the C<User-Agent> header in
+the requests.
 
-If the $product_id ends with space then the _agent() string is
-appended to it.
-
-The user agent string should be one or more simple product identifiers
-with an optional version number separated by the "/" character.
-Examples are:
+The default is a string of the form C<libwww-perl/#.###>, where C<#.###> is
+substituted with the version number of this library.
 
-  $ua->agent('Checkbot/0.4 ' . $ua->_agent);
-  $ua->agent('Checkbot/0.4 ');    # same as above
-  $ua->agent('Mozilla/5.0');
-  $ua->agent("");                 # don't identify
+If the provided string ends with space, the default C<libwww-perl/#.###>
+string is appended to it.
 
-=item $ua->_agent
-
-Returns the default agent identifier.  This is a string of the form
-"libwww-perl/#.###", where "#.###" is substituted with the version number
-of this library.
-
-=item $ua->from
-
-=item $ua->from( $email_address )
+The user agent string should be one or more simple product identifiers
+with an optional version number separated by the C</> character.
 
-Get/set the e-mail address for the human user who controls
-the requesting user agent.  The address should be machine-usable, as
-defined in RFC 822.  The C<from> value is send as the "From" header in
-the requests.  Example:
+=head2 conn_cache
 
-  $ua->from('gaas@cpan.org');
+    my $cache_obj = $ua->conn_cache;
+    $ua->conn_cache( $cache_obj );
 
-The default is to not send a "From" header.  See the default_headers()
-method for the more general interface that allow any header to be defaulted.
+Get/set the L<LWP::ConnCache> object to use.  See L<LWP::ConnCache>
+for details.
 
-=item $ua->cookie_jar
+=head2 cookie_jar
 
-=item $ua->cookie_jar( $cookie_jar_obj )
+    my $jar = $ua->cookie_jar;
+    $ua->cookie_jar( $cookie_jar_obj );
 
 Get/set the cookie jar object to use.  The only requirement is that
-the cookie jar object must implement the extract_cookies($response) and
-add_cookie_header($request) methods.  These methods will then be
+the cookie jar object must implement the C<extract_cookies($response)> and
+C<add_cookie_header($request)> 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<HTTP::Cookies> object or some
 subclass.
 
-The default is to have no cookie_jar, i.e. never automatically add
-"Cookie" headers to the requests.
+The default is to have no cookie jar, i.e. never automatically add
+C<Cookie> headers to the requests.
 
-Shortcut: If a reference to a plain hash is passed in as the
-$cookie_jar_object, then it is replaced with an instance of
-L<HTTP::Cookies> that is initialized based on the hash.  This form also
-automatically loads the L<HTTP::Cookies> module.  It means that:
+Shortcut: If a reference to a plain hash is passed in, it is replaced with an
+instance of L<HTTP::Cookies> that is initialized based on the hash. This form
+also automatically loads the L<HTTP::Cookies> module.  It means that:
 
   $ua->cookie_jar({ file => "$ENV{HOME}/.cookies.txt" });
 
@@ -1272,86 +1262,106 @@ is really just a shortcut for:
   require HTTP::Cookies;
   $ua->cookie_jar(HTTP::Cookies->new(file => "$ENV{HOME}/.cookies.txt"));
 
-=item $ua->default_headers
+=head2 credentials
 
-=item $ua->default_headers( $headers_obj )
+    my $creds = $ua->credentials();
+    $ua->credentials( $netloc, $realm );
+    $ua->credentials( $netloc, $realm, $uname, $pass );
+    $ua->credentials("www.example.com:80", "Some Realm", "foo", "secret");
 
-Get/set the headers object that will provide default header values for
-any requests sent.  By default this will be an empty L<HTTP::Headers>
-object.
+Get/set the user name and password to be used for a realm.
 
-=item $ua->default_header( $field )
+The C<$netloc> is a string of the form C<< <host>:<port> >>.  The username and
+password will only be passed to this server.
 
-=item $ua->default_header( $field => $value )
+=head2 default_header
 
-This is just a short-cut for $ua->default_headers->header( $field =>
-$value ). Example:
+    $ua->default_header( $field );
+    $ua->default_header( $field => $value );
+    $ua->default_header('Accept-Encoding' => scalar HTTP::Message::decodable());
+    $ua->default_header('Accept-Language' => "no, en");
 
-  $ua->default_header('Accept-Encoding' => scalar HTTP::Message::decodable());
-  $ua->default_header('Accept-Language' => "no, en");
+This is just a shortcut for
+C<< $ua->default_headers->header( $field => $value ) >>.
 
-=item $ua->conn_cache
+=head2 default_headers
 
-=item $ua->conn_cache( $cache_obj )
+    my $headers = $ua->default_headers;
+    $ua->default_headers( $headers_obj );
 
-Get/set the L<LWP::ConnCache> object to use.  See L<LWP::ConnCache>
-for details.
+Get/set the headers object that will provide default header values for
+any requests sent.  By default this will be an empty L<HTTP::Headers>
+object.
 
-=item $ua->credentials( $netloc, $realm )
+=head2 from
 
-=item $ua->credentials( $netloc, $realm, $uname, $pass )
+    my $from = $ua->from;
+    $ua->from('foo@bar.com');
 
-Get/set the user name and password to be used for a realm.
+Get/set the email address for the human user who controls
+the requesting user agent.  The address should be machine-usable, as
+defined in L<RFC2822|https://tools.ietf.org/html/rfc2822>. The C<from> value
+is sent as the C<From> header in the requests.
 
-The $netloc is a string of the form "<host>:<port>".  The username and
-password will only be passed to this server.  Example:
+The default is to not send a C<From> header.  See
+L<LWP::UserAgent/default_headers> for the more general interface that allow
+any header to be defaulted.
 
-  $ua->credentials("www.example.com:80", "Some Realm", "foo", "secret");
 
-=item $ua->local_address
+=head2 local_address
 
-=item $ua->local_address( $address )
+    my $address = $ua->local_address;
+    $ua->local_address( $address );
 
 Get/set the local interface to bind to for network connections.  The interface
 can be specified as a hostname or an IP address.  This value is passed as the
 C<LocalAddr> argument to L<IO::Socket::INET>.
 
-=item $ua->max_size
+=head2 max_redirect
+
+    my $max = $ua->max_redirect;
+    $ua->max_redirect( $n );
 
-=item $ua->max_size( $bytes )
+This reads or sets the object's limit of how many times it will obey
+redirection responses in a given request cycle.
+
+By default, the value is C<7>. This means that if you call L<LWP::UserAgent/request>
+and the response is a redirect elsewhere which is in turn a
+redirect, and so on seven times, then LWP gives up after that seventh
+request.
+
+=head2 max_size
+
+    my $size = $ua->max_size;
+    $ua->max_size( $bytes );
 
 Get/set the size limit for response content.  The default is C<undef>,
 which means that there is no limit.  If the returned response content
 is only partial, because the size limit was exceeded, then a
-"Client-Aborted" header will be added to the response.  The content
+C<Client-Aborted> header will be added to the response.  The content
 might end up longer than C<max_size> as we abort once appending a
-chunk of data makes the length exceed the limit.  The "Content-Length"
+chunk of data makes the length exceed the limit.  The C<Content-Length>
 header, if present, will indicate the length of the full content and
 will normally not be the same as C<< length($res->content) >>.
 
-=item $ua->max_redirect
+=head2 parse_head
 
-=item $ua->max_redirect( $n )
-
-This reads or sets the object's limit of how many times it will obey
-redirection responses in a given request cycle.
-
-By default, the value is 7. This means that if you call request()
-method and the response is a redirect elsewhere which is in turn a
-redirect, and so on seven times, then LWP gives up after that seventh
-request.
-
-=item $ua->parse_head
-
-=item $ua->parse_head( $boolean )
+    my $bool = $ua->parse_head;
+    $ua->parse_head( $boolean );
 
 Get/set a value indicating whether we should initialize response
 headers from the E<lt>head> section of HTML documents. The default is
-TRUE.  Do not turn this off, unless you know what you are doing.
+true. I<Do not turn this off> unless you know what you are doing.
 
-=item $ua->protocols_allowed
+=head2 protocols_allowed
 
-=item $ua->protocols_allowed( \@protocols )
+    my $aref = $ua->protocols_allowed;      # get allowed protocols
+    $ua->protocols_allowed( \@protocols );  # allow ONLY these
+    $ua->protocols_allowed(undef);          # delete the list
+    $ua->protocols_allowed(['http',]);      # ONLY allow http
+
+By default, an object has neither a C<protocols_allowed> list, nor a
+L<LWP::UserAgent/protocols_forbidden> list.
 
 This reads (or sets) this user agent's list of protocols that the
 request methods will exclusively allow.  The protocol names are case
@@ -1360,19 +1370,17 @@ insensitive.
 For example: C<< $ua->protocols_allowed( [ 'http', 'https'] ); >>
 means that this user agent will I<allow only> those protocols,
 and attempts to use this user agent to access URLs with any other
-schemes (like "ftp://...") will result in a 500 error.
-
-To delete the list, call: C<< $ua->protocols_allowed(undef) >>
-
-By default, an object has neither a C<protocols_allowed> list, nor a
-C<protocols_forbidden> list.
+schemes (like C<ftp://...>) will result in a 500 error.
 
 Note that having a C<protocols_allowed> list causes any
-C<protocols_forbidden> list to be ignored.
+L<LWP::UserAgent/protocols_forbidden> list to be ignored.
 
-=item $ua->protocols_forbidden
+=head2 protocols_forbidden
 
-=item $ua->protocols_forbidden( \@protocols )
+    my $aref = $ua->protocols_forbidden;    # get the forbidden list
+    $ua->protocols_forbidden(\@protocols);  # do not allow these
+    $ua->protocols_forbidden(['http',]);    # All http reqs get a 500
+    $ua->protocols_forbidden(undef);        # delete the list
 
 This reads (or sets) this user agent's list of protocols that the
 request method will I<not> allow. The protocol names are case
@@ -1383,43 +1391,32 @@ means that this user agent will I<not> allow those protocols, and
 attempts to use this user agent to access URLs with those schemes
 will result in a 500 error.
 
-To delete the list, call: C<< $ua->protocols_forbidden(undef) >>
-
-=item $ua->requests_redirectable
+=head2 requests_redirectable
 
-=item $ua->requests_redirectable( \@requests )
+    my $aref = $ua->requests_redirectable;
+    $ua->requests_redirectable( \@requests );
+    $ua->requests_redirectable(['GET', 'HEAD',]); # the default
 
 This reads or sets the object's list of request names that
-C<< $ua->redirect_ok(...) >> will allow redirection for.  By
-default, this is C<['GET', 'HEAD']>, as per RFC 2616.  To
-change to include 'POST', consider:
+L<LWP::UserAgent/redirect_ok> will allow redirection for. By default, this
+is C<['GET', 'HEAD']>, as per L<RFC 2616|https://tools.ietf.org/html/rfc2616>.
+To change to include C<POST>, consider:
 
    push @{ $ua->requests_redirectable }, 'POST';
 
-=item $ua->show_progress
+=head2 show_progress
 
-=item $ua->show_progress( $boolean )
+    my $bool = $ua->show_progress;
+    $ua->show_progress( $boolean );
 
 Get/set a value indicating whether a progress bar should be displayed
-on the terminal as requests are processed. The default is FALSE.
+on the terminal as requests are processed. The default is false.
 
-=item $ua->timeout
+=head2 ssl_opts
 
-=item $ua->timeout( $secs )
-
-Get/set the timeout value in seconds. The default timeout() value is
-180 seconds, i.e. 3 minutes.
-
-The requests is aborted if no activity on the connection to the server
-is observed for C<timeout> seconds.  This means that the time it takes
-for the complete transaction and the request() method to actually
-return might be longer.
-
-=item $ua->ssl_opts
-
-=item $ua->ssl_opts( $key )
-
-=item $ua->ssl_opts( $key => $value )
+    my @keys = $ua->ssl_opts;
+    my $val = $ua->ssl_opts( $key );
+    $ua->ssl_opts( $key => $value );
 
 Get/set the options for SSL connections.  Without argument return the list
 of options keys currently set.  With a single argument return the current
@@ -1463,41 +1460,29 @@ The libwww-perl core no longer bundles protocol plugins for SSL.  You will need
 to install L<LWP::Protocol::https> separately to enable support for processing
 https-URLs.
 
-=back
-
-=head2 Proxy attributes
+=head2 timeout
 
-The following methods set up when requests should be passed via a
-proxy server.
+    my $secs = $ua->timeout;
+    $ua->timeout( $secs );
 
-=over
-
-=item $ua->proxy(\@schemes, $proxy_url)
-
-=item $ua->proxy($scheme, $proxy_url)
-
-Set/retrieve proxy URL for a scheme:
-
- $ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');
- $ua->proxy('gopher', 'http://proxy.sn.no:8001/');
-
-The first form specifies that the URL is to be used as a proxy for
-access methods listed in the list in the first method argument,
-i.e. 'http' and 'ftp'.
+Get/set the timeout value in seconds. The default value is
+180 seconds, i.e. 3 minutes.
 
-The second form shows a shorthand form for specifying
-proxy URL for a single access scheme.
+The requests is aborted if no activity on the connection to the server
+is observed for C<timeout> seconds.  This means that the time it takes
+for the complete transaction and the L<LWP::UserAgent/request> method to
+actually return might be longer.
 
-=item $ua->no_proxy( $domain, ... )
+=head1 PROXY ATTRIBUTES
 
-Do not proxy requests to the given domains.  Calling no_proxy without
-any domains clears the list of domains. For example:
+The following methods set up when requests should be passed via a
+proxy server.
 
- $ua->no_proxy('localhost', 'example.com');
+=head2 env_proxy
 
-=item $ua->env_proxy
+    $ua->env_proxy;
 
-Load proxy settings from *_proxy environment variables.  You might
+Load proxy settings from C<*_proxy> environment variables.  You might
 specify proxies like this (sh-syntax):
 
   gopher_proxy=http://proxy.my.place/
@@ -1510,36 +1495,77 @@ environment variables.
 
 On systems with case insensitive environment variables there exists a
 name clash between the CGI environment variables and the C<HTTP_PROXY>
-environment variable normally picked up by env_proxy().  Because of
+environment variable normally picked up by C<env_proxy>.  Because of
 this C<HTTP_PROXY> is not honored for CGI scripts.  The
 C<CGI_HTTP_PROXY> environment variable can be used instead.
 
-=back
+=head2 no_proxy
+
+    $ua->no_proxy( @domains );
+    $ua->no_proxy('localhost', 'example.com');
+    $ua->no_proxy(); # clear the list
+
+Do not proxy requests to the given domains.  Calling C<no_proxy> without
+any domains clears the list of domains.
+
+=head2 proxy
+
+    $ua->proxy(\@schemes, $proxy_url)
+    $ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');
+    # or, for a single scheme
+    $ua->proxy($scheme, $proxy_url)
+    $ua->proxy('gopher', 'http://proxy.sn.no:8001/');
 
-=head2 Handlers
+Set/retrieve proxy URL for a scheme.
+
+The first form specifies that the URL is to be used as a proxy for
+access methods listed in the list in the first method argument,
+i.e. C<http> and C<ftp>.
+
+The second form shows a shorthand form for specifying
+proxy URL for a single access scheme.
+
+=head1 HANDLERS
 
 Handlers are code that injected at various phases during the
 processing of requests.  The following methods are provided to manage
 the active handlers:
 
-=over
+=head2 add_handler
 
-=item $ua->add_handler( $phase => \&cb, %matchspec )
+    $ua->add_handler( $phase => \&cb, %matchspec )
 
 Add handler to be invoked in the given processing phase.  For how to
-specify %matchspec see L<HTTP::Config/"Matching">.
+specify C<%matchspec> see L<HTTP::Config/"Matching">.
 
-The possible values $phase and the corresponding callback signatures are:
+The possible values C<$phase> and the corresponding callback signatures are:
 
 =over
 
-=item request_preprepare => sub { my($request, $ua, $h) = @_; ... }
+=item response_data => sub { my($response, $ua, $h, $data) = @_; ... }
 
-The handler is called before the C<request_prepare> and other standard
-initialization of the request.  This can be used to set up headers
-and attributes that the C<request_prepare> handler depends on.  Proxy
-initialization should take place here; but in general don't register
-handlers for this phase.
+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, $h) = @_; ... }
+
+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_header => sub { my($response, $ua, $h) = @_; ... }
+
+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 $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 $ua->request() method
+was called with a $content_file or $content_cb argument; otherwise true.
 
 =item request_prepare => sub { my($request, $ua, $h) = @_; ... }
 
@@ -1554,6 +1580,14 @@ 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, $h) = @_; ... }
+
+The handler is called before the C<request_prepare> and other standard
+initialization of the request.  This can be used to set up headers
+and attributes that the C<request_prepare> 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, $h) = @_; ... }
 
 This handler gets a chance of handling requests before they're sent to the
@@ -1563,31 +1597,6 @@ wishes to terminate the processing; otherwise it should return nothing.
 The C<response_header> and C<response_data> handlers will not be
 invoked for this response, but the C<response_done> will be.
 
-=item response_header => sub { my($response, $ua, $h) = @_; ... }
-
-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 $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 $ua->request() method
-was called with a $content_file or $content_cb argument; otherwise true.
-
-=item response_data => sub { my($response, $ua, $h, $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, $h) = @_; ... }
-
-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, $h) = @_; ... }
 
 The handler is called in $ua->request after C<response_done>.  If the
@@ -1596,53 +1605,71 @@ this request instead.
 
 =back
 
-=item $ua->remove_handler( undef, %matchspec )
+=head2 get_my_handler
 
-=item $ua->remove_handler( $phase, %matchspec )
+    $ua->get_my_handler( $phase, %matchspec );
+    $ua->get_my_handler( $phase, %matchspec, $init );
 
-Remove handlers that match the given %matchspec.  If $phase is not
-provided remove handlers from all phases.
+Will retrieve the matching handler as hash ref.
 
-Be careful as calling this function with %matchspec that is not
-specific enough can remove handlers not owned by you.  It's probably
-better to use the set_my_handler() method instead.
+If C<$init> is passed as a true value, create and add the
+handler if it's not found.  If C<$init> is a subroutine reference, then
+it's called with the created handler hash as argument.  This sub might
+populate the hash with extra fields; especially the callback.  If
+C<$init> is a hash reference, merge the hashes.
 
-The removed handlers are returned.
+=head2 handlers
 
-=item $ua->set_my_handler( $phase, $cb, %matchspec )
+    $ua->handlers( $phase, $request )
+    $ua->handlers( $phase, $response )
 
-Set handlers private to the executing subroutine.  Works by defaulting
-an C<owner> field to the %matchspec that holds the name of the called
-subroutine.  You might pass an explicit C<owner> to override this.
+Returns the handlers that apply to the given request or response at
+the given processing phase.
 
-If $cb is passed as C<undef>, remove the handler.
+=head2 remove_handler
 
-=item $ua->get_my_handler( $phase, %matchspec )
+    $ua->remove_handler( undef, %matchspec );
+    $ua->remove_handler( $phase, %matchspec );
+    $ua->remove_handlers(); # REMOVE ALL HANDLERS IN ALL PHASES
 
-=item $ua->get_my_handler( $phase, %matchspec, $init )
+Remove handlers that match the given C<%matchspec>.  If C<$phase> is not
+provided, remove handlers from all phases.
 
-Will retrieve the matching handler as hash ref.
+Be careful as calling this function with C<%matchspec> that is not
+specific enough can remove handlers not owned by you.  It's probably
+better to use the L<LWP::UserAgent/set_my_handler> method instead.
 
-If C<$init> is passed as a TRUE value, create and add the
-handler if it's not found.  If $init is a subroutine reference, then
-it's called with the created handler hash as argument.  This sub might
-populate the hash with extra fields; especially the callback.  If
-$init is a hash reference, merge the hashes.
+The removed handlers are returned.
 
-=item $ua->handlers( $phase, $request )
+=head2 set_my_handler
 
-=item $ua->handlers( $phase, $response )
+    $ua->set_my_handler( $phase, $cb, %matchspec );
+    $ua->set_my_handler($phase, undef); # remove handler for phase
 
-Returns the handlers that apply to the given request or response at
-the given processing phase.
+Set handlers private to the executing subroutine.  Works by defaulting
+an C<owner> field to the C<%matchspec> that holds the name of the called
+subroutine.  You might pass an explicit C<owner> to override this.
 
-=back
+If $cb is passed as C<undef>, remove the handler.
 
 =head1 REQUEST METHODS
 
 The methods described in this section are used to dispatch requests
 via the user agent.  The following request methods are provided:
 
+=head2 delete
+
+    my $res = $ua->delete( $url );
+    my $res = $ua->delete( $url, $field_name => $value, ... );
+
+This method will dispatch a C<DELETE> request on the given URL.  Additional
+headers and content options are the same as for the L<LWP::UserAgent/get>
+method.
+
+This method will use the DELETE() function from L<HTTP::Request::Common>
+to build the request.  See L<HTTP::Request::Common> for a details on
+how to pass form content and other advanced features.
+
 =head2 get
 
     my $res = $ua->get( $url );
@@ -1705,6 +1732,44 @@ response returned by the get() function.
 This method will dispatch a C<HEAD> request on the given URL.
 Otherwise it works like the L<LWP::UserAgent/get> method described above.
 
+=head2 is_protocol_supported
+
+    my $bool = $ua->is_protocol_supported( $scheme );
+
+You can use this method to test whether this user agent object supports the
+specified C<scheme>.  (The C<scheme> might be a string (like C<http> or
+C<ftp>) or it might be an L<URI> object reference.)
+
+Whether a scheme is supported is determined by the user agent's
+C<protocols_allowed> or C<protocols_forbidden> lists (if any), and by
+the capabilities of LWP.  I.e., this will return true only if LWP
+supports this protocol I<and> it's permitted for this particular
+object.
+
+=head2 is_online
+
+    my $bool = $ua->is_online;
+
+Tries to determine if you have access to the Internet. Returns C<1> (true)
+if the built-in heuristics determine that the user agent is
+able to access the Internet (over HTTP) or C<0> (false).
+
+See also L<LWP::Online>.
+
+=head2 mirror
+
+    my $res = $ua->mirror( $url, $filename );
+
+This method will get the document identified by URL and store it in
+file called C<$filename>.  If the file already exists, then the request
+will contain an C<If-Modified-Since> header matching the modification
+time of the file.  If the document on the server has not changed since
+this time, then nothing happens.  If the document has been updated, it
+will be downloaded again.  The modification time of the file will be
+forced to match that of the server.
+
+The return value is an L<HTTP::Response> object.
+
 =head2 post
 
     my $res = $ua->post( $url, \%form );
@@ -1751,33 +1816,6 @@ This method will use the C<PUT> function from L<HTTP::Request::Common>
 to build the request.  See L<HTTP::Request::Common> for a details on
 how to pass form content and other advanced features.
 
-=head2 delete
-
-    my $res = $ua->delete( $url );
-    my $res = $ua->delete( $url, $field_name => $value, ... );
-
-This method will dispatch a C<DELETE> request on the given URL.  Additional
-headers and content options are the same as for the L<LWP::UserAgent/get>
-method.
-
-This method will use the DELETE() function from L<HTTP::Request::Common>
-to build the request.  See L<HTTP::Request::Common> for a details on
-how to pass form content and other advanced features.
-
-=head2 mirror
-
-    my $res = $ua->mirror( $url, $filename );
-
-This method will get the document identified by URL and store it in
-file called C<$filename>.  If the file already exists, then the request
-will contain an C<If-Modified-Since> header matching the modification
-time of the file.  If the document on the server has not changed since
-this time, then nothing happens.  If the document has been updated, it
-will be downloaded again.  The modification time of the file will be
-forced to match that of the server.
-
-The return value is an L<HTTP::Response> object.
-
 =head2 request
 
     my $res = $ua->request( $request );
@@ -1828,63 +1866,12 @@ The difference from L<LWP::Simple/request> is that C<simple_request> will not tr
 handle redirects or authentication responses.  The L<LWP::Simple/request> method
 will, in fact, invoke this method for each simple request it sends.
 
-=head2 is_online
-
-    my $bool = $ua->is_online;
-
-Tries to determine if you have access to the Internet. Returns C<1> (true)
-if the built-in heuristics determine that the user agent is
-able to access the Internet (over HTTP) or C<0> (false).
-
-See also L<LWP::Online>.
-
-=head2 is_protocol_supported
-
-    my $bool = $ua->is_protocol_supported( $scheme );
-
-You can use this method to test whether this user agent object supports the
-specified C<scheme>.  (The C<scheme> might be a string (like C<http> or
-C<ftp>) or it might be an L<URI> object reference.)
-
-Whether a scheme is supported is determined by the user agent's
-C<protocols_allowed> or C<protocols_forbidden> lists (if any), and by
-the capabilities of LWP.  I.e., this will return true only if LWP
-supports this protocol I<and> it's permitted for this particular
-object.
-
-=head1 Callback methods
+=head1 CALLBACK METHODS
 
 The following methods will be invoked as requests are processed. These
 methods are documented here because subclasses of L<LWP::UserAgent>
 might want to override their behaviour.
 
-=head2 prepare_request
-
-    $request = $ua->prepare_request( $request );
-
-This method is invoked by L<LWP::UserAgent/simple_request>. Its task is
-to modify the given C<$request> object by setting up various headers based
-on the attributes of the user agent. The return value should normally be the
-C<$request> object passed in.  If a different request object is returned
-it will be the one actually processed.
-
-The headers affected by the base implementation are; C<User-Agent>,
-C<From>, C<Range> and C<Cookie>.
-
-=head2 redirect_ok
-
-    my $bool = $ua->redirect_ok( $prospective_request, $response );
-
-This method is called by L<LWP::UserAgent/request> before it tries to follow a
-redirection to the request in C<$response>.  This should return a true
-value if this redirection is permissible.  The C<$prospective_request>
-will be the request to be sent if this method returns true.
-
-The base implementation will return false unless the method
-is in the object's C<requests_redirectable> list,
-false if the proposed redirection is to a C<file://...>
-URL, and true otherwise.
-
 =head2 get_basic_credentials
 
     # This checks wantarray and can either return an array:
@@ -1906,6 +1893,19 @@ with this library.
 The base implementation simply checks a set of pre-stored member
 variables, set up with the L<LWP::UserAgent/credentials> method.
 
+=head2 prepare_request
+
+    $request = $ua->prepare_request( $request );
+
+This method is invoked by L<LWP::UserAgent/simple_request>. Its task is
+to modify the given C<$request> object by setting up various headers based
+on the attributes of the user agent. The return value should normally be the
+C<$request> object passed in.  If a different request object is returned
+it will be the one actually processed.
+
+The headers affected by the base implementation are; C<User-Agent>,
+C<From>, C<Range> and C<Cookie>.
+
 =head2 progress
 
     my $prog = $ua->progress( $status, $request_or_response );
@@ -1920,6 +1920,20 @@ if the fraction can't be calculated.
 When C<$status> is "begin" the second argument is the L<HTTP::Request> object,
 otherwise it is the L<HTTP::Response> object.
 
+=head2 redirect_ok
+
+    my $bool = $ua->redirect_ok( $prospective_request, $response );
+
+This method is called by L<LWP::UserAgent/request> before it tries to follow a
+redirection to the request in C<$response>.  This should return a true
+value if this redirection is permissible.  The C<$prospective_request>
+will be the request to be sent if this method returns true.
+
+The base implementation will return false unless the method
+is in the object's C<requests_redirectable> list,
+false if the proposed redirection is to a C<file://...>
+URL, and true otherwise.
+
 =head1 SEE ALSO
 
 See L<LWP> for a complete overview of libwww-perl5.  See L<lwpcook>
diff --git a/t/base/protocols/nntp.t b/t/base/protocols/nntp.t
new file mode 100644 (file)
index 0000000..c53873c
--- /dev/null
@@ -0,0 +1,12 @@
+use strict;
+use warnings;
+
+use LWP::UserAgent ();
+use Test::More;
+use Test::RequiresInternet ( 'nntp.perl.org' => 119 );
+
+plan tests => 1;
+my $ua = LWP::UserAgent->new;
+
+my $res = $ua->get('nntp://nntp.perl.org/blahblahblah@blahblahblah');
+is($res->code, 404, '404 on fake nntp url');
index d136cae7c6ef734c2085aef4a3519d890985da3e..aed1716c2c279a218156c92f0050b31b14e5c71e 100644 (file)
@@ -38,6 +38,7 @@ my @files = (
     't/00-report-prereqs.t',
     't/base/default_content_type.t',
     't/base/protocols.t',
+    't/base/protocols/nntp.t',
     't/base/proxy.t',
     't/base/simple.t',
     't/base/ua.t',
index dd1a5a7953d657f80524429d231002ac898a6374..dd61176b25a6a5b0918932a2a4123e4afcbcc850 100644 (file)
@@ -26,21 +26,21 @@ plan skip_all => 'All the modules we found were excluded from POD coverage test.
 plan tests => scalar @modules;
 
 my %trustme = (
-             'LWP::RobotUA' => [
-                               qr/^host_count$/
-                             ],
-             'LWP::UserAgent' => [
-                                 qr/^(?:run_handlers|send_request|use_alarm|use_eval)$/
-                               ],
              'LWP::Protocol' => [
                                 qr/^(?:max_size|timeout)$/
                               ],
+             'LWP::UserAgent' => [
+                                 qr/^(?:run_handlers|send_request|use_alarm|use_eval)$/
+                               ],
+             'LWP::Protocol::gopher' => [
+                                        qr/^(?:gopher2url|menu2html)$/
+                                      ],
              'LWP::Protocol::http' => [
                                       qr/^(?:hlist_remove|socket_class|socket_type)$/
                                     ],
-             'LWP::Protocol::gopher' => [
-                                        qr/^(?:gopher2url|menu2html)$/
-                                      ]
+             'LWP::RobotUA' => [
+                               qr/^host_count$/
+                             ]
            );
 
 my @also_private;
index b0cb1f8cc1a3023eb8d0b718180778bfd43ef306..b6fe178a388f18c8f513d2626d914e3ac4cc0285 100644 (file)
@@ -271,6 +271,8 @@ file
 freeerider
 ftp
 gerhard
+getprint
+getstore
 gisle
 github
 gong
index a6a6e90cbce1d2f89c6df7664b1d28c6de9a7d3a..47d17c4480bedfd2b8999487bdb6ecdd514ddf09 100644 (file)
@@ -4,7 +4,7 @@ use Test::More tests => 2;
 
 note 'Checking Changes';
 my $changes_file = 'Changes';
-my $newver = '6.22';
+my $newver = '6.23';
 my $trial_token = '-TRIAL';
 
 SKIP: {