r41036 - in /branches/upstream/libpoe-component-client-http-perl/current: ./ lib/POE/Component/Client/ lib/POE/Component/Client/HTTP/ lib/POE/Filter/ t/

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Thu Jul 30 21:51:17 UTC 2009


Author: jawnsy-guest
Date: Thu Jul 30 21:51:11 2009
New Revision: 41036

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=41036
Log:
[svn-upgrade] Integrating new upstream version, libpoe-component-client-http-perl (0.890)

Added:
    branches/upstream/libpoe-component-client-http-perl/current/t/59_incomplete_b.t
Modified:
    branches/upstream/libpoe-component-client-http-perl/current/CHANGES
    branches/upstream/libpoe-component-client-http-perl/current/MANIFEST
    branches/upstream/libpoe-component-client-http-perl/current/META.yml
    branches/upstream/libpoe-component-client-http-perl/current/Makefile.PL
    branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP.pm
    branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP/Request.pm
    branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Filter/HTTPHead.pm
    branches/upstream/libpoe-component-client-http-perl/current/t/01_request.t
    branches/upstream/libpoe-component-client-http-perl/current/t/02_keepalive.t
    branches/upstream/libpoe-component-client-http-perl/current/t/08_discard.t
    branches/upstream/libpoe-component-client-http-perl/current/t/10_shutdown.t
    branches/upstream/libpoe-component-client-http-perl/current/t/55_reiss_double_resp.t

Modified: branches/upstream/libpoe-component-client-http-perl/current/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/CHANGES?rev=41036&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/CHANGES (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/CHANGES Thu Jul 30 21:51:11 2009
@@ -1,3 +1,54 @@
+==================================
+2009-07-28T06:25:31.783332Z v0_890
+==================================
+
+  2009-07-28 06:21:07 (r369) by rcaputo; Makefile.PL M
+
+    Use the latest POE::Component::Client::Keepalive, too.
+
+  2009-07-28 06:20:01 (r368) by rcaputo
+  lib/POE/Component/Client/HTTP.pm M; Makefile.PL M
+
+    Use latest POE, and prepare for a new release.
+
+  2009-07-27 04:53:43 (r367) by rcaputo
+  lib/POE/Component/Client/HTTP.pm M; Makefile.PL M
+
+    Added a machine-readable repository directory to the distribution.
+    Documented the bug tracker, repository, and other resource URLs. 
+
+  2009-07-26 23:03:04 (r366) by rcaputo; t/59_incomplete_b.t A
+
+    Forgot to add this test in the last commit.
+
+  2009-07-26 23:01:30 (r365) by rcaputo
+  t/01_request.t M; t/01_stream.t M; t/10_shutdown.t M;
+  lib/POE/Component/Client/HTTP.pm M; t/08_discard.t M; MANIFEST M;
+  t/55_reiss_double_resp.t M; lib/POE/Filter/HTTPHead.pm M;
+  lib/POE/Component/Client/HTTP/Request.pm M; t/02_keepalive.t M
+
+    Resolve a long-standing debate between MaxSize and Content-Length
+    headers. If the Content-Length is greater than MaxSize, or the length
+    of the content is (in the case where there is no Content-Length
+    header), then we return a 406 Not Acceptable error rather than
+    truncated data.
+    
+    Users who want truncated data should issue range requests instead of
+    relying upon MaxSize. Besides, MaxSize won't let you resume your
+    request where it left off.
+    
+    Resolves rt.cpan.org ticket 26874. 
+
+  2009-07-26 17:33:10 (r364) by rcaputo
+  lib/POE/Component/Client/HTTP/Request.pm M
+
+    Internal component errors are sometimes indistinguishable from
+    external server errors. Add a bit of text to differentiate them. 
+
+  2009-03-07 15:47:52 (r363) by martijn; t/01_request.t M
+
+    apply patch from Apocalypse to make invalid host test more robust 
+
 =================================
 2009-02-19T07:14:44.152645Z v0_88
 =================================
@@ -174,141 +225,6 @@
     and by updating t/58_joel_cancel_multi.t to my version because the
     changes in trunk were assuming the non-local tests. 
 
-=================================
-2008-07-13T08:07:37.418057Z v0_85
-=================================
-
-  2008-07-13 08:07:22 (r334) by rcaputo
-  lib/POE/Component/Client/HTTP.pm M
-
-    Time for another release.
-
-  2008-07-13 06:26:14 (r333) by rcaputo
-  lib/POE/Component/Client/HTTP.pm M; t/57_joel_immed_cancel.t M;
-  t/58_joel_cancel_multi.t M
-
-    Don't die when canceling requests or shutting down components. 
-
-  2008-07-09 19:44:56 (r332) by martijn; t/04_chunk_filter.t M
-
-    forget about reading from DATA. This way we can control how much data
-    we feed to the filter, so we get better coverage. 
-
-  2008-07-09 19:44:41 (r331) by martijn; t/04_chunk_filter.t M
-
-    de-poe-ify 04_chunk_filter.t too. 
-
-  2008-07-09 19:44:21 (r330) by martijn; t/03_head_filter.t M
-
-    get coverage up to same level as with the old tests. 
-
-  2008-07-09 19:44:07 (r329) by martijn; t/03_head_filter.t M
-
-    stop using POE while testing Filter::HTTPHead. 
-
-=================================
-2008-05-28T17:35:59.670622Z v0_84
-=================================
-
-  2008-05-28 17:33:06 (r327) by rcaputo
-  lib/POE/Component/Client/HTTP.pm M; t/14_gzipped_content.t M;
-  lib/POE/Component/Client/HTTP/Request.pm M
-
-    Resolve Content-Encoding issue surfaced by recent changes to
-    HTTP::Response. Applies the fix recommeded by Yuri Karaban in
-    rt.cpan.org ticket 35538. 
-
-  2008-05-04 06:57:15 (r326) by rcaputo
-  lib/POE/Component/Client/HTTP/Request.pm M
-
-    Resolve character encoding issues arising from a change in
-    HTTP::Message's decoded_content() behavior. Tentatively resolves
-    rt.cpan.org ticket 35538, reported by Yuri Karaban, with additional
-    commentary and a test case by "OverlordQ". 
-
-  2008-04-20 00:34:15 (r325) by rcaputo; MANIFEST M
-
-    Add t/59_andy_one_keepalive.t 
-
-=================================
-2008-04-20T00:30:17.408340Z v0_83
-=================================
-
-  2008-04-20 00:29:46 (r323) by rcaputo
-  lib/POE/Component/Client/HTTP.pm M
-
-    Release time! 
-
-  2008-04-20 00:26:49 (r322) by rcaputo
-  lib/POE/Component/Client/HTTP.pm M
-
-    Apply Kim Scheibel's patch to support a BindAddress parameter. Useful
-    for running on multi-homed machines. Resolves rt.cpan.org ticket
-    34837. 
-
-  2008-04-19 22:56:52 (r321) by rcaputo
-  lib/POE/Component/Client/HTTP.pm M
-
-    Apply Yuri Karaban's patch to avoid losing responses when a redirect
-    fails. Resolves rt.cpan.org ticket 25577. 
-
-  2008-04-19 22:46:23 (r320) by rcaputo
-  lib/POE/Filter/HTTPChunk.pm M; lib/POE/Component/Client/HTTP.pm M
-
-    Apply Yuri Karaban's patch to respond correctly if the server closes
-    connection before sending headers. Resolves rt.cpan.org ticket 25920. 
-
-  2008-03-25 07:51:12 (r319) by rcaputo; lib/POE/Filter/HTTPHead.pm M
-
-    Apply Jeffrey Posnick's patch to support duplicate headers. Before
-    his patch, subsequent headers of the same type would overwrite
-    previous ones. For example, a second Cookie header would clobber the
-    first. Resolves rt.cpan.org 27262. 
-
-  2008-03-25 07:42:11 (r318) by rcaputo
-  lib/POE/Component/Client/HTTP/Request.pm M
-
-    Apply Dan Sterling's patch to use Time::HiRes when it's available. He
-    was running into premature timeouts when using subsecond timeouts.
-    Resolves rt.cpan.org 30466. 
-
-  2008-03-24 18:05:00 (r317) by rcaputo; Makefile.PL M
-
-    Rely on the latest POE::Component::Client::Keepalive, which includes
-    a fix for a common noisy POE::Kernel trap. 
-
-  2008-03-24 18:03:29 (r316) by rcaputo
-  lib/POE/Component/Client/HTTP/Request.pm M
-
-    Apply Andrew Sterling Hanenkamp's patch to not pass cookies across
-    redirects. Previously cookie headers would bleed with a redirect,
-    which is extremely bad. Resolves rt.cpan.org ticket 30400. 
-
-  2008-03-24 17:53:15 (r315) by rcaputo
-  lib/POE/Component/Client/HTTP/Request.pm M
-
-    Apply Andrew Sterling Hanenkamp's suggestion not to bail out of
-    redirect if we reach the same URL twice. It was doing the wrong thing
-    with certain site authentication schemes. Resolves rt.cpan.org ticket
-    30399. 
-
-  2008-03-24 17:44:53 (r314) by rcaputo
-  lib/POE/Component/Client/HTTP/Request.pm M
-
-    Apply Andrew Sterling Hannenkamp's patch to frob redirect cookies
-    (they count!). Resolves rt.cpan.org ticket 30401. 
-
-  2007-08-17 13:54:25 (r313) by andyg; t/59_andy_one_keepalive.t A
-
-    A failing test for reusing a single keep-alive connection (run with
-    DEBUG)
-
-  2007-05-20 12:50:02 (r312) by martijn
-  lib/POE/Component/Client/HTTP/Request.pm M
-
-    r955 at kazad-dum: martijn | 2007-05-20 12:06:14 +0200 spell my name
-    right :) 
-
 ==============
 End of Excerpt
 ==============

Modified: branches/upstream/libpoe-component-client-http-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/MANIFEST?rev=41036&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/MANIFEST (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/MANIFEST Thu Jul 30 21:51:11 2009
@@ -1,4 +1,4 @@
-# $Id: MANIFEST 360 2009-02-19 07:09:22Z rcaputo $
+# $Id: MANIFEST 365 2009-07-26 23:01:30Z rcaputo $
 CHANGES
 CHANGES.OLD
 MANIFEST
@@ -33,3 +33,4 @@
 t/56_redirect_excess.t
 t/57_pravus_progress.t
 t/58_joel_cancel_multi.t
+t/59_incomplete_b.t

Modified: branches/upstream/libpoe-component-client-http-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/META.yml?rev=41036&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/META.yml (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/META.yml Thu Jul 30 21:51:11 2009
@@ -1,20 +1,31 @@
 --- #YAML:1.0
-name:                POE-Component-Client-HTTP
-version:             0.88
-abstract:            Non-blocking/concurrent HTTP queries with POE
-license:             perl
-author:              
+name:               POE-Component-Client-HTTP
+version:            0.890
+abstract:           Non-blocking/concurrent HTTP queries with POE
+author:
     - Rocco Caputo <rcaputo at cpan.org>
-generated_by:        ExtUtils::MakeMaker version 6.42
-distribution_type:   module
-requires:     
-    HTTP::Request:                 1.3
-    HTTP::Response:                1.37
-    Net::HTTP::Methods:            0.02
-    POE:                           0.3202
-    POE::Component::Client::Keepalive: 0.25
-    Test::POE::Server::TCP:        0
-    URI:                           1.24
+license:            perl
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    HTTP::Request:        1.3
+    HTTP::Response:       1.37
+    Net::HTTP::Methods:   0.02
+    POE:                  1.007
+    POE::Component::Client::Keepalive:  0.26
+    Test::POE::Server::TCP:  0
+    URI:                  1.24
+resources:
+    license:     http://dev.perl.org/licenses/
+    repository:  http://thirdlobe.com/svn/poco-client-http/trunk
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.54
 meta-spec:
-    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
-    version: 1.3
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Modified: branches/upstream/libpoe-component-client-http-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/Makefile.PL?rev=41036&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/Makefile.PL (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/Makefile.PL Thu Jul 30 21:51:11 2009
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# $Id: Makefile.PL 351 2008-12-09 06:17:03Z rcaputo $
+# $Id: Makefile.PL 369 2009-07-28 06:21:07Z rcaputo $
 
 use strict;
 use lib qw(./mylib);
@@ -9,12 +9,12 @@
 open(CHANGES, ">>CHANGES") and close CHANGES;
 
 my %prereq = (
-  'POE'                => 0.3202,
+  'POE'                => 1.007,
   'HTTP::Request'      => 1.30,
   'HTTP::Response'     => 1.37,
   'URI'                => 1.24,
   'Net::HTTP::Methods' => 0.02,
-  'POE::Component::Client::Keepalive' => 0.25,
+  'POE::Component::Client::Keepalive' => 0.260,
   'Test::POE::Server::TCP' => 0,
 );
 
@@ -26,6 +26,12 @@
   LICENSE      => 'perl',
   VERSION_FROM => 'lib/POE/Component/Client/HTTP.pm',
   PREREQ_PM    => \%prereq,
+  META_ADD     => {
+    resources  => {
+      license    => 'http://dev.perl.org/licenses/',
+      repository => 'http://thirdlobe.com/svn/poco-client-http/trunk'
+    },
+  },
   dist         => {
     COMPRESS   => 'gzip -9f',
     SUFFIX     => 'gz',

Modified: branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP.pm?rev=41036&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP.pm (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP.pm Thu Jul 30 21:51:11 2009
@@ -1,4 +1,4 @@
-# $Id: HTTP.pm 361 2009-02-19 07:14:19Z rcaputo $
+# $Id: HTTP.pm 368 2009-07-28 06:20:01Z rcaputo $
 
 package POE::Component::Client::HTTP;
 
@@ -11,7 +11,7 @@
 use constant DEBUG_DATA => 0;
 
 use vars qw($VERSION);
-$VERSION = '0.88';
+$VERSION = '0.890';
 
 use Carp qw(croak);
 use HTTP::Response;
@@ -470,6 +470,7 @@
 
   $request->[REQ_STATE] ^= RS_SENDING;
   $request->[REQ_STATE] = RS_IN_HEAD;
+
   # XXX - Removed a second time.  The first time was in version 0.53,
   # because the EOF generated by shutdown_output() causes some servers
   # to disconnect rather than send their responses.
@@ -628,8 +629,8 @@
 
     # Some responses are without content by definition
     # FIXME: #12363
-    #        Make sure we finish even when it isn't one of these,
-    #        but there is no content.
+    # Make sure we finish even when it isn't one of these, but there
+    # is no content.
     if (
       $request->[REQ_HTTP_REQUEST]->method eq 'HEAD'
       or $input->code =~ /^(?:1|[23]04)/
@@ -655,6 +656,23 @@
       return;
     }
     else {
+      # If we have content length, and it's more than the maximum we
+      # requested, then fail without bothering with the content.
+      if (
+        defined($heap->{factory}->max_response_size())
+        and defined($input->content_length())
+        and $input->content_length() > $heap->{factory}->max_response_size()
+      ) {
+        _internal_cancel(
+          $heap, $request_id, 406,
+          "Response content length " . $input->content_length() .
+          " is greater than specified MaxSize of " .
+          $heap->{factory}->max_response_size() .
+          ".  Use range requests to retrieve specific amounts of content."
+        );
+        return;
+      }
+
       $request->[REQ_STATE] |= RS_IN_CONTENT;
       $request->[REQ_STATE] &= ~RS_IN_HEAD;
       #FIXME: probably want to find out when the content from this
@@ -1469,7 +1487,7 @@
 
 =item
 
-Copyright 1999-2006 Rocco Caputo
+Copyright 1999-2009 Rocco Caputo
 
 =item
 
@@ -1493,16 +1511,17 @@
 Jeff Bisbee added POD tests and documentation to pass several of them
 to version 0.79.  He's a kwalitee-increasing machine!
 
-=head1 CONTACT
-
-Rocco may be contacted by e-mail via L<mailto:rcaputo at cpan.org>, and
-Martijn may be contacted by email via L<mailto:martijn at cpan.org>.
-
-The preferred way to report bugs or requests is through RT though.
-See L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=POE-Component-Client-HTTP>
-or mail L<mailto:bug-POE-Component-Client-HTTP at rt.cpan.org>
-
-For questions, try the L<POE> mailing list (poe at perl.org)
+=head1 BUG TRACKER
+
+https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=POE-Component-Client-HTTP
+
+=head1 REPOSITORY
+
+http://thirdlobe.com/svn/poco-client-http/
+
+=head1 OTHER RESOURCES
+
+http://search.cpan.org/dist/POE-Component-Client-HTTP/
 
 =cut
 

Modified: branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP/Request.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP/Request.pm?rev=41036&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP/Request.pm (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP/Request.pm Thu Jul 30 21:51:11 2009
@@ -1,4 +1,4 @@
-# $Id: Request.pm 359 2009-02-19 05:20:37Z rcaputo $
+# $Id: Request.pm 365 2009-07-26 23:01:30Z rcaputo $
 
 package POE::Component::Client::HTTP::Request;
 use strict;
@@ -227,7 +227,7 @@
       "got " . $self->[REQ_OCTETS_GOT] . " of " .
       $self->[REQ_RESPONSE]->content_length
     );
-    #TODO: shouldn't this be 406 as per RT #20975?
+
     $self->error(
       400,
       "incomplete response b " . $self->[REQ_ID] . ".  Wanted " .
@@ -259,23 +259,29 @@
   # therein.  If it's done the former, then we're safe.  Otherwise
   # we also need to C<use bytes>.
   # TODO: write test(s) for this.
+
   my $this_chunk_length = length($self->[REQ_BUFFER]);
   $self->[REQ_OCTETS_GOT] += $this_chunk_length;
 
-  my $max = $self->[REQ_FACTORY]->max_response_size;
+  my $max = $self->[REQ_FACTORY]->max_response_size();
 
   DEBUG and warn(
     "REQ: request ", $self->ID,
     " received $self->[REQ_OCTETS_GOT] bytes; maximum is $max"
   );
 
+  # Fail if we've gone over the maximum content size to return.
   if (defined $max and $self->[REQ_OCTETS_GOT] > $max) {
-    # We've gone over the maximum content size to return.  Chop it # back.
-    my $over = $self->[REQ_OCTETS_GOT] - $max;
-    $self->[REQ_OCTETS_GOT] -= $over;
-    substr($self->[REQ_BUFFER], -$over) = "";
-    #TODO: ??
-    #$self->[REQ_STATE] |= RS_DONE;
+    $self->error(
+      406,
+      "Response content is longer than specified MaxSize of $max.  " .
+      "Use range requests to retrieve specific amounts of content."
+    );
+
+    $self->[REQ_STATE] |= RS_DONE;
+    $self->[REQ_STATE] &= ~RS_IN_CONTENT;
+    $self->[REQ_CONNECTION]->close();
+    return 1;
   }
 
   # keep this for the progress callback (it gets cleared in return_response
@@ -300,16 +306,6 @@
     );
   };
 
-  if (defined $max and $self->[REQ_OCTETS_GOT] >= $max) {
-    DEBUG and warn(
-      "REQ: request ", $self->ID, " has a full response... moving to done."
-    );
-    $self->[REQ_STATE] |= RS_DONE;
-    $self->[REQ_STATE] &= ~RS_IN_CONTENT;
-    $self->[REQ_CONNECTION]->close();
-    return 1;
-  }
-
   if ($self->[REQ_RESPONSE]->content_length) {
 
     # Report back progress
@@ -331,6 +327,7 @@
       return 1;
     }
   }
+
   return 0;
 }
 
@@ -535,6 +532,7 @@
     . "<BODY>$nl"
     . "<H1>Error: $http_msg</H1>$nl"
     . "$message$nl"
+    . "<small>This is a client error, not a server error.</small>$nl"
     . "</BODY>$nl"
     . "</HTML>$nl"
   );

Modified: branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Filter/HTTPHead.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Filter/HTTPHead.pm?rev=41036&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Filter/HTTPHead.pm (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Filter/HTTPHead.pm Thu Jul 30 21:51:11 2009
@@ -1,4 +1,4 @@
-# $Id: HTTPHead.pm 319 2008-03-25 07:51:12Z rcaputo $
+# $Id: HTTPHead.pm 365 2009-07-26 23:01:30Z rcaputo $
 
 package POE::Filter::HTTPHead_Line;
 use warnings;
@@ -55,8 +55,9 @@
       }
       else {
         # assume HTTP/0.9
-        my $resp = HTTP::Response->new ('200', 'OK',
-                    ['Content-Type' => 'text/html'], $line );
+        my $resp = HTTP::Response->new (
+          '200', 'OK', ['Content-Type' => 'text/html'], $line
+        );
         $resp->protocol('HTTP/0.9');
         return [ $resp ];
       }

Modified: branches/upstream/libpoe-component-client-http-perl/current/t/01_request.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/t/01_request.t?rev=41036&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/t/01_request.t (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/t/01_request.t Thu Jul 30 21:51:11 2009
@@ -66,7 +66,7 @@
   );
   my $port = $_[HEAP]->{testd}->port;
   my @badrequests = (
-    GET("http://not.localhost/badhost"),
+    GET("http://not.localhost.but.invalid/badhost"),
     GET("file:///from/a/local/filesystem"),
   );
 
@@ -162,7 +162,7 @@
   elsif ($request_path =~ m/\/post\d$/ and $response->code == 200) {
     pass('got 200 response for post request')
   }
-  elsif ($request_path =~ m/\/long$/ and $response->code == 400) {
+  elsif ($request_path =~ m/\/long$/ and $response->code == 406) {
     pass('got 400 response for long request')
   }
   elsif ($request_path =~ m/badhost$/ and $response->code == 500) {

Modified: branches/upstream/libpoe-component-client-http-perl/current/t/02_keepalive.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/t/02_keepalive.t?rev=41036&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/t/02_keepalive.t (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/t/02_keepalive.t Thu Jul 30 21:51:11 2009
@@ -1,4 +1,4 @@
-# $Id: 02_keepalive.t 354 2009-02-18 06:19:51Z rcaputo $
+# $Id: 02_keepalive.t 365 2009-07-26 23:01:30Z rcaputo $
 # vim: filetype=perl sts=2 sw=2
 use strict;
 
@@ -151,7 +151,7 @@
 # Create a weeble component.
 POE::Component::Client::HTTP->spawn(
   #MaxSize           => MAX_BIG_REQUEST_SIZE,
-  Timeout           => 1,
+  Timeout           => 2,
   ConnectionManager => $cm,
 );
 

Modified: branches/upstream/libpoe-component-client-http-perl/current/t/08_discard.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/t/08_discard.t?rev=41036&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/t/08_discard.t (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/t/08_discard.t Thu Jul 30 21:51:11 2009
@@ -1,5 +1,5 @@
 #! /usr/bin/perl
-# $Id: 08_discard.t 273 2006-09-25 17:16:03Z rcaputo $
+# $Id: 08_discard.t 365 2009-07-26 23:01:30Z rcaputo $
 # -*- perl -*-
 # vim: filetype=perl
 
@@ -16,7 +16,7 @@
 
 POE::Component::Client::HTTP->spawn(
  Alias => 'ua',
- Timeout => 1
+ Timeout => 2,
 );
 
 # We are testing against a localhost server.

Modified: branches/upstream/libpoe-component-client-http-perl/current/t/10_shutdown.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/t/10_shutdown.t?rev=41036&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/t/10_shutdown.t (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/t/10_shutdown.t Thu Jul 30 21:51:11 2009
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-# $Id: 10_shutdown.t 354 2009-02-18 06:19:51Z rcaputo $
+# $Id: 10_shutdown.t 365 2009-07-26 23:01:30Z rcaputo $
 # vim: filetype=perl
 
 use strict;
@@ -16,7 +16,7 @@
 plan tests => 2;
 
 # Create a weeble component.
-POE::Component::Client::HTTP->spawn( Timeout => 1 );
+POE::Component::Client::HTTP->spawn( Timeout => 2 );
 
 # Create a session that will make some requests.
 POE::Session->create(

Modified: branches/upstream/libpoe-component-client-http-perl/current/t/55_reiss_double_resp.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/t/55_reiss_double_resp.t?rev=41036&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/t/55_reiss_double_resp.t (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/t/55_reiss_double_resp.t Thu Jul 30 21:51:11 2009
@@ -12,7 +12,7 @@
 use HTTP::Request::Common 'GET';
 
 sub POE_ASSERT_DEFAULT () { 1 }
-sub DEBUG () { 0 }
+sub DEBUG ()              { 0 }
 
 use Test::More tests => 9;
 
@@ -25,29 +25,35 @@
 my @responses;
 
 my @cases = (
-    [ 
-      1,
-      sub { [
-        "HTTP/1.1 302 Moved$CRLF" .
-        "Location: http://127.0.0.1:${port}/stuff$CRLF" .
-        "Connection: close$CRLF" .
-        "Content-type: text/plain$CRLF" . $CRLF .
-        "Line 1 of the redirect",
+  {
+    number => 1,
+    tries_left => 1,
+    request => sub {
+      [
+        "HTTP/1.1 302 Moved$CRLF"
+          . "Location: http://127.0.0.1:${port}/stuff$CRLF"
+          . "Connection: close$CRLF"
+          . "Content-type: text/plain$CRLF"
+          . $CRLF
+          . "Line 1 of the redirect",
         "Line 2 of the redirect",
         "Line 3 of the redirect",
-        "", # keep the connection open, maybe
-        "",
-        "",
-        "",
-      ] },
-    ],
-    [ 
-      2, 
-      sub { [
-        "HTTP/1.1 200 OK$CRLF" .
-        "Connection: close$CRLF" .
-        "Content-type: text/plain$CRLF$CRLF" .
-        ( "Too Much" x 64 ),
+        "",    # keep the connection open, maybe
+        "",
+        "",
+        "",
+      ];
+    },
+  },
+  {
+    number => 2,
+    tries_left => 2,
+    request => sub {
+      [
+        "HTTP/1.1 200 OK$CRLF"
+          . "Connection: close$CRLF"
+          . "Content-type: text/plain$CRLF$CRLF"
+          . ("Too Much" x 64),
         "",
         "",
         "",
@@ -60,127 +66,155 @@
         "should not appear",
         "should not appear",
         "should not appear"
-      ] },
-    ]  
+      ];
+    },
+  }
 );
 
 my $case = shift @cases;
 spawn_server();
 
 sub set_responses {
-  @responses = $case->[1]->();
-}
+  # Sub call to create a new copy each time.
+  @responses = $case->{request}->();
+}
+
+### Server.
 
 my $server_alias;
+
 sub spawn_server {
-  $server_alias = "server$case";
+  $server_alias = "server_$case->{number}";
   POE::Component::Server::TCP->new(
-    Alias               => $server_alias,
-    Address             => "127.0.0.1",
-    Port                => 0,
-    Started             => \&register_port,
-    ClientConnected     => \&connected,
-    ClientInputFilter   => "POE::Filter::Line",
-    ClientOutputFilter  => "POE::Filter::Stream",
-    ClientInput         => \&parse_next_request,
-    Concurrency         => 1,
-    InlineStates => {
-      next_part => \&next_part
-    },
+    Alias              => $server_alias,
+    Address            => "127.0.0.1",
+    Port               => 0,
+    Started            => \&register_port,
+    ClientConnected    => \&connected,
+    ClientInputFilter  => "POE::Filter::Line",
+    ClientOutputFilter => "POE::Filter::Stream",
+    ClientInput        => \&parse_next_request,
+    Concurrency        => 1,
+    InlineStates       => {next_part => \&next_part},
   );
 }
-  
-  sub connected {
-    DEBUG and diag "new connection";
-    $_[KERNEL]->post( $server_alias => 'shutdown' );
-  }
-
-  sub register_port {
-    $port = (sockaddr_in($_[HEAP]->{listener}->getsockname()))[0];
-    set_responses();
-  }
-
-  sub next_part {
-    my $left = $_[ARG0];
-    my $next = shift @$left;
-
-    if (!$_[HEAP]->{client}) {
-        $_[KERNEL]->yield('shutdown');
-        return;
-    }
-
-    $_[HEAP]->{client}->put($next);
-
-    $next =~ s/$CRLF/{CRLF}/g;
-
-    DEBUG and warn "sent [$next]\n";
-    
-    if (@$left) {  
-        $_[KERNEL]->delay(next_part => 0.1 => $left);
-    } else {
-        $_[KERNEL]->yield('shutdown');
-    }
-  }
-
-  sub parse_next_request {
-    my $input = $_[ARG0];
-
-    DEBUG and diag "got line: [$input]";
-    return if $input ne "";
-
-    if (!$_[HEAP]->{in_progress}++) {
-      my $response = pop @responses;
-      $_[KERNEL]->yield(next_part => [ @$response ]);
-    }
-  }
-
+
+sub connected {
+  DEBUG and diag "server: received new connection - shutting down";
+  $_[KERNEL]->post($server_alias => 'shutdown');
+}
+
+sub register_port {
+  $port = (sockaddr_in($_[HEAP]->{listener}->getsockname()))[0];
+  set_responses();
+}
+
+sub next_part {
+  my $left = $_[ARG0];
+  my $next = shift @$left;
+
+  if (!$_[HEAP]->{client}) {
+    $_[KERNEL]->yield('shutdown');
+    return;
+  }
+
+  $_[HEAP]->{client}->put($next);
+
+  DEBUG and diag "server: sent [$next]\n";
+
+  if (@$left) {
+    $_[KERNEL]->delay(next_part => 0.1 => $left);
+  }
+  else {
+    $_[KERNEL]->yield('shutdown');
+  }
+}
+
+sub parse_next_request {
+  my $input = $_[ARG0];
+
+  DEBUG and diag "server: received [$input]";
+  return if $input ne "";
+
+  if (!$_[HEAP]->{in_progress}++) {
+    my $response = pop @responses;
+    $_[KERNEL]->yield(next_part => [@$response]);
+  }
+}
+
+### CLIENT
 
 # Spawn the HTTP user-agent component.
 POE::Component::Client::HTTP->spawn(
-    FollowRedirects => 3,
-    MaxSize => 512,
+  FollowRedirects => 3,
+  MaxSize         => 512,
+  Timeout         => 2,
 );
 
 # Create a client session to drive the HTTP component.
 POE::Session->create(
   inline_states => {
-    _start => sub { 
-      $_[KERNEL]->call($_[SESSION] => 'begin');
+    _start => sub {
+      $_[KERNEL]->yield('begin');
     },
     begin => sub {
+      # Request a redirect.
       $_[KERNEL]->post(
-        weeble => request => response =>
-        GET "http://127.0.0.1:${port}/"
+        weeble => request => response => GET "http://127.0.0.1:${port}/"
       );
     },
     response => sub {
       my $response = $_[ARG1][0];
-      my $content = $response->content();
+      my $content  = $response->content();
 
       $content =~ s/\x0D/{CR}/g;
       $content =~ s/\x0A/{LF}/g;
 
       pass "got a response, content = ($content)";
 
-      ok(defined $response->request, "response has corresponding request object set");
-
-      if ($case->[0] == 1) {
-        # last response should be non-OK in each set
-        ok($response->code != 200, "response status is _not_ OK");
-      } else {
-        ok($response->code == 200, "response status is OK");
-      }
-
-      if (--$case->[0]) {
-        DEBUG and diag "request left in this set";
+      ok(
+        defined $response->request,
+        "response has corresponding request object set"
+      );
+
+      if ($case->{number} == 1) {
+        # Case 1 redirects to a dead port.  We should get a 400.
+        is($response->code, 500, "case 1 redirect to dead server returns 500");
+      }
+      elsif ($case->{number} == 2) {
+        if ($case->{tries_left} == 2) {
+          # Case 2.2 tests whether excess content triggers socket reuse.
+          is($response->code, 406, "case 2.2 response is too long");
+        }
+        elsif ($case->{tries_left} == 1) {
+          # Case 2.1 redirects to a dead port.  We should get a 400.
+          is($response->code, 500, "case 2.1 redirect to dead server = 500");
+        }
+      }
+
+      $case->{tries_left}--;
+
+      # Somehow we got too many responses.
+      if ($case->{tries_left} < 0) {
+        fail("too many responses");
+        return;
+      }
+
+      # There are tries remaining in this case.  Try again.
+      if ($case->{tries_left}) {
+        DEBUG and diag "client: requests left in this set";
         $_[KERNEL]->delay('begin' => 0.6);
-      } elsif (@cases) {
-        $case = shift @cases;
-        spawn_server();
-        $_[KERNEL]->yield('begin');
-      }
-    },
-    _stop => sub { exit },  # Nasty but expedient.
+        return;
+      }
+
+      # We're done if no cases remain.
+      return unless @cases;
+
+      # Next case, please.
+      $case = shift @cases;
+      spawn_server();
+      $_[KERNEL]->yield('begin');
+    },
   }
 );
 

Added: branches/upstream/libpoe-component-client-http-perl/current/t/59_incomplete_b.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/t/59_incomplete_b.t?rev=41036&op=file
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/t/59_incomplete_b.t (added)
+++ branches/upstream/libpoe-component-client-http-perl/current/t/59_incomplete_b.t Thu Jul 30 21:51:11 2009
@@ -1,0 +1,120 @@
+# vim: filetype=perl ts=2 sw=2 expandtab
+use strict;
+use warnings;
+use HTTP::Request;
+use HTTP::Status;
+use Test::More;
+
+plan tests => 4;
+
+use constant DEBUG => 0;
+
+sub POE::Kernel::TRACE_EVENTS ()     { 0 }
+sub POE::Kernel::TRACE_REFCNT ()     { 0 }
+sub POE::Kernel::CATCH_EXCEPTIONS () { 0 }
+use Test::POE::Server::TCP;
+use POE qw(Filter::Stream Component::Client::HTTP);
+
+POE::Component::Client::HTTP->spawn(
+  Alias   => 'ua',
+  MaxSize => 50,
+  Timeout => 2,
+);
+
+POE::Session->create(
+  inline_states => {
+    _start             => \&client_start,
+    response           => \&response_handler,
+    testd_registered   => \&testd_start,
+    testd_client_input => \&testd_input,
+  }
+);
+
+our %responses;
+POE::Kernel->run;
+
+exit;
+
+sub client_start {
+  my ($kernel, $heap) = @_[KERNEL, HEAP];
+
+  DEBUG and warn "client starting...\n";
+
+  $heap->{testd} = Test::POE::Server::TCP->spawn(
+    Filter  => POE::Filter::Stream->new,
+    address => 'localhost',
+  );
+}
+
+sub testd_start {
+  my ($kernel, $heap) = @_[KERNEL, HEAP];
+
+  my $port = $heap->{testd}->port;
+
+  $kernel->post(
+    ua => request => response =>
+    HTTP::Request->new('GET', "http://localhost:$port/content_length")
+  );
+
+  $kernel->post(
+    ua => request => response =>
+    HTTP::Request->new('GET', "http://localhost:$port/no_length")
+  );
+
+  $heap->{query_count} = 2;
+}
+
+sub testd_input {
+  my ($kernel, $heap, $id, $input) = @_[KERNEL, HEAP, ARG0, ARG1];
+
+  my $content_length_data = <<'EOF';
+HTTP/1.1 200 OK
+Content-Length: 60
+
+123456789
+123456789
+123456789
+123456789
+123456789
+123456789
+EOF
+
+  my $no_content_length_data = <<'EOF';
+HTTP/1.1 200 OK
+
+123456789
+123456789
+123456789
+123456789
+123456789
+123456789
+EOF
+
+  if ($input =~ /(?:content_length)/) {
+    pass("got expected content-length request");
+    $heap->{testd}->send_to_client($id, $content_length_data);
+  }
+  elsif ($input =~ /(?:no_length)/) {
+    pass("got expected no-content-length request");
+    $heap->{testd}->send_to_client($id, $no_content_length_data);
+  }
+  else {
+    BAIL_OUT("got a request that isn't even supposed to exist");
+  }
+}
+
+sub response_handler {
+  my $heap     = $_[HEAP];
+  my $response = $_[ARG1][0];
+  my $request  = $_[ARG0][0];
+
+  my $path = $request->uri->path;
+  if ($path eq '/content_length') {
+    is($response->code, 406, 'content-length triggered 406');
+  }
+  elsif ($path eq '/no_length') {
+    is($response->code, 406, 'length(content) triggered 406');
+  }
+
+  $heap->{testd}->shutdown() unless --$heap->{query_count};
+}




More information about the Pkg-perl-cvs-commits mailing list