r69292 - 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
Tue Feb 22 01:19:36 UTC 2011


Author: jawnsy-guest
Date: Tue Feb 22 01:19:29 2011
New Revision: 69292

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

Added:
    branches/upstream/libpoe-component-client-http-perl/current/t/60_rt50231_pending.t
    branches/upstream/libpoe-component-client-http-perl/current/t/60_rt50231_pending_many.t
Removed:
    branches/upstream/libpoe-component-client-http-perl/current/moo.pl
    branches/upstream/libpoe-component-client-http-perl/current/pcchget.perl
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/README
    branches/upstream/libpoe-component-client-http-perl/current/README.mkdn
    branches/upstream/libpoe-component-client-http-perl/current/dist.ini
    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/Component/Client/HTTP/RequestFactory.pm
    branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Filter/HTTPChunk.pm
    branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Filter/HTTPHead.pm

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=69292&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/CHANGES (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/CHANGES Tue Feb 22 01:19:29 2011
@@ -1,3 +1,49 @@
+================================
+2011-02-20 23:51:41 -0500 v0_942
+================================
+
+  commit 5b052d5d2d238f6af470958e4ed33e5453119e2e
+  Author: Rocco Caputo <rcaputo at cpan.org>
+  Date:   Sun Feb 20 23:51:41 2011 -0500
+  
+    Bump the version for release.
+
+  commit cf963d64dcb3f60f56bcfa493b04b7eb0f5f8a7e
+  Author: Apocalypse <perl at 0ne.us>
+  Date:   Sun Jan 30 15:35:54 2011 -0700
+  
+    Add tests for pending_requests_count() and fix underlying cause of
+    RT#50231, thanks Jeff Bisbee 
+
+================================
+2011-02-20 22:56:33 -0500 v0_941
+================================
+
+  commit f89255d7f0a801600c8533f0931a7d31e615116c
+  Author: Rocco Caputo <rcaputo at cpan.org>
+  Date:   Sun Feb 20 22:56:33 2011 -0500
+  
+    Remove explicit VERSION assignments so dzil can do it for us.
+
+  commit f1ddf1cfea5bfa8e4d1c365ab8735941653dfc52
+  Author: Rocco Caputo <rcaputo at cpan.org>
+  Date:   Mon Feb 14 10:52:13 2011 -0500
+  
+    Bump the version for release.
+
+  commit 38412e1f9c0afdd0d338c75f9a9c45e87c32911d
+  Author: Rocco Caputo <rcaputo at cpan.org>
+  Date:   Sun Feb 13 14:50:44 2011 -0500
+  
+    Make notes (marked with "TODO CONNECT") where SSL CONNECT proxying
+    logic might go.
+
+  commit 3562e58dd084ca86630003dede755326a7cdbf92
+  Author: Rocco Caputo <rcaputo at cpan.org>
+  Date:   Sun Feb 13 14:25:18 2011 -0500
+  
+    Remove "patches welcome" for IPv6. 
+
 ================================
 2011-01-27 17:02:36 -0500 v0_910
 ================================
@@ -113,29 +159,6 @@
   
     Test and docs fixes. 
 
-================================
-2010-02-15 01:19:25 -0500 v0_895
-================================
-
-  commit a312f51daeb5b95422b8cd1fc80226d23d3e38d5
-  Author: Rocco Caputo <rcaputo at cpan.org>
-  Date:   Mon Feb 15 01:19:25 2010 -0500
-  
-    Bump the revision for a new release.
-
-  commit 38323e64b15d9e6c8d540bb70ed88a058bfa9453
-  Author: Rocco Caputo <rcaputo at cpan.org>
-  Date:   Mon Feb 15 00:57:05 2010 -0500
-  
-    [rt.cpan.org 48354] Fix line parsing for excessively small streaming
-    sizes.
-
-  commit f18a1d1c89333d6715caf713ebe63ee0f19dd914
-  Author: Rocco Caputo <rcaputo at cpan.org>
-  Date:   Mon Feb 15 00:55:23 2010 -0500
-  
-    Fix a vim modeline. No significant changes. 
-
 ===================================
 End of changes in the last 365 days
 ===================================

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=69292&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/MANIFEST (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/MANIFEST Tue Feb 22 01:19:29 2011
@@ -14,8 +14,6 @@
 lib/POE/Component/Client/HTTP/RequestFactory.pm
 lib/POE/Filter/HTTPChunk.pm
 lib/POE/Filter/HTTPHead.pm
-moo.pl
-pcchget.perl
 t/000-report-versions.t
 t/01_request.t
 t/01_ssl.t
@@ -42,5 +40,7 @@
 t/57_pravus_progress.t
 t/58_joel_cancel_multi.t
 t/59_incomplete_b.t
+t/60_rt50231_pending.t
+t/60_rt50231_pending_many.t
 t/release-pod-coverage.t
 t/release-pod-syntax.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=69292&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/META.yml (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/META.yml Tue Feb 22 01:19:29 2011
@@ -20,11 +20,11 @@
   HTTP::Status: 5.811
   Net::HTTP::Methods: 5.812
   POE: 1.299
-  POE::Component::Client::Keepalive: 0.265
+  POE::Component::Client::Keepalive: 0.266
   Socket::GetAddrInfo: 0.19
   Test::More: 0.96
   Test::POE::Server::TCP: 1.14
   URI: 1.37
 resources:
   repository: git://github.com/rcaputo/poe-component-client-http.git
-version: 0.910
+version: 0.942

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=69292&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/Makefile.PL (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/Makefile.PL Tue Feb 22 01:19:29 2011
@@ -27,13 +27,13 @@
     'HTTP::Status' => '5.811',
     'Net::HTTP::Methods' => '5.812',
     'POE' => '1.299',
-    'POE::Component::Client::Keepalive' => '0.265',
+    'POE::Component::Client::Keepalive' => '0.266',
     'Socket::GetAddrInfo' => '0.19',
     'Test::More' => '0.96',
     'Test::POE::Server::TCP' => '1.14',
     'URI' => '1.37'
   },
-  'VERSION' => '0.910',
+  'VERSION' => '0.942',
   'test' => {
     'TESTS' => 't/*.t'
   }

Modified: branches/upstream/libpoe-component-client-http-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/README?rev=69292&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/README (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/README Tue Feb 22 01:19:29 2011
@@ -2,7 +2,7 @@
     POE::Component::Client::HTTP - a HTTP user-agent component
 
 VERSION
-    version 0.910
+    version 0.942
 
 SYNOPSIS
       use POE qw(Component::Client::HTTP);
@@ -290,6 +290,11 @@
 
       my $count = $kernel->call('ua' => 'pending_requests_count');
 
+    NOTE: Sometimes the count might not be what you expected, because
+    responses are currently in POE's queue and you haven't processed them.
+    This could happen if you configure the "ConnectionManager"'s concurrency
+    to a high enough value.
+
   cancel
     Cancel a specific HTTP request. Requires a reference to the original
     request (blessed or stringified) so it knows which one to cancel. See
@@ -438,8 +443,6 @@
     to find the remote server's address without having to make an additional
     request.
 
-    Patches for IPv6 support are welcome.
-
 ENVIRONMENT
     POE::Component::Client::HTTP uses two standard environment variables:
     HTTP_PROXY and NO_PROXY.

Modified: branches/upstream/libpoe-component-client-http-perl/current/README.mkdn
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/README.mkdn?rev=69292&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/README.mkdn (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/README.mkdn Tue Feb 22 01:19:29 2011
@@ -4,7 +4,7 @@
 
 # VERSION
 
-version 0.910
+version 0.942
 
 # SYNOPSIS
 
@@ -317,6 +317,10 @@
 
   my $count = $kernel->call('ua' => 'pending_requests_count');
 
+NOTE: Sometimes the count might not be what you expected, because responses
+are currently in POE's queue and you haven't processed them. This could happen
+if you configure the `ConnectionManager`'s concurrency to a high enough value.
+
 ## cancel
 
 Cancel a specific HTTP request.  Requires a reference to the original
@@ -479,8 +483,6 @@
 means to find the remote server's address without having to make an
 additional request.
 
-Patches for IPv6 support are welcome.
-
 # ENVIRONMENT
 
 POE::Component::Client::HTTP uses two standard environment variables:

Modified: branches/upstream/libpoe-component-client-http-perl/current/dist.ini
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/dist.ini?rev=69292&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/dist.ini (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/dist.ini Tue Feb 22 01:19:29 2011
@@ -1,5 +1,5 @@
 name              = POE-Component-Client-HTTP
-version           = 0.910
+version           = 0.942
 author            = Rocco Caputo <rcaputo at cpan.org>
 license           = Perl_5
 copyright_holder  = Rocco Caputo
@@ -12,7 +12,7 @@
 HTTP::Status                      = 5.811
 Net::HTTP::Methods                = 5.812
 POE                               = 1.299
-POE::Component::Client::Keepalive = 0.265
+POE::Component::Client::Keepalive = 0.266
 Socket::GetAddrInfo               = 0.19
 Test::More                        = 0.96
 Test::POE::Server::TCP            = 1.14

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=69292&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 Tue Feb 22 01:19:29 2011
@@ -1,4 +1,7 @@
 package POE::Component::Client::HTTP;
+BEGIN {
+  $POE::Component::Client::HTTP::VERSION = '0.942';
+}
 # vim: ts=2 sw=2 expandtab
 
 # {{{ INIT
@@ -8,9 +11,6 @@
 
 use constant DEBUG      => 0;
 use constant DEBUG_DATA => 0;
-
-use vars qw($VERSION);
-$VERSION = '0.895';
 
 use Carp qw(croak);
 use HTTP::Response;
@@ -277,6 +277,10 @@
 
   eval {
     # get a connection from Client::Keepalive
+    #
+    # TODO CONNECT - We must ask PCC::Keepalive to establish an http
+    # socket, not https.  The initial proxy interactin is plaintext?
+
     $request->[REQ_CONN_ID] = $heap->{cm}->allocate(
       scheme  => $request->scheme,
       addr    => $request->host,
@@ -445,7 +449,7 @@
 
     # Well, we have a response.  Isn't that nice?  Let's send it.
     if ($request->[REQ_STATE] & (RS_IN_CONTENT | RS_DONE)) {
-      _finish_request($heap, $request, 0);
+      _finish_request($heap, $request);
       return;
     }
 
@@ -519,9 +523,10 @@
 
   # Drop the wheel.
   my $request_id = delete $heap->{wheel_to_request}->{$wheel_id};
-  #K or die "!!!: unexpectedly undefined request ID" unless defined $request_id;
 
   # There was no corresponding request?  Nothing left to do here.
+  # We might have got here because the server sent EOF after we were done processing
+  # the request, and deleted it from our cache. ( notes for RT#50231 )
   return unless $request_id;
 
   DEBUG and warn "I/O: removing request $request_id";
@@ -556,7 +561,7 @@
     $request->[REQ_STATE] & (RS_IN_CONTENT | RS_DONE) and
     not $request->[REQ_STATE] & RS_POSTED
   ) {
-    _finish_request($heap, $request, 0);
+    _finish_request($heap, $request);
     return;
   }
 
@@ -625,9 +630,10 @@
   DEBUG and warn "I/O: wheel $wheel_id got input...";
   DEBUG_DATA and warn (ref($input) ? $input->as_string : _hexdump($input));
 
-  # TODO - So, which is it?  Return, or die?
+  # There was no corresponding request?  Nothing left to do here.
+  # We might have got here because the server sent EOF after we were done processing
+  # the request, and deleted it from our cache. ( notes for RT#50231 )
   return unless defined $request_id;
-  die unless defined $request_id;
 
   my $request = $heap->{request}->{$request_id};
   return unless defined $request;
@@ -664,6 +670,25 @@
     # include a status line.  See t/53_response_parser.t.
     $request->[REQ_RESPONSE] = $input;
     $input->header("X-PCCH-Peer", $request->[REQ_PEERNAME]);
+
+    # TODO CONNECT - If we've got the headers to a CONNECT request,
+    # then we can switch to the actual request.  This is like a faux
+    # redirect where the socket gets reused.
+    #
+    # 1. Switch the socket to SSL.
+    # 2. Switch the request from CONNECT mode to regular mode, using
+    #    the method proposed in PCCH::Request.
+    # 3. Send the original request via PCCH::Request->send_to_wheel().
+    #    This puts the client back into the RS_SENDING state.
+    # 4. Reset any data/state so it appears we never went through
+    #    CONNECT.
+    # 5. Make sure that PCC::Keepalive will discard the socket when
+    #    we're done with it.
+    # 6. Return.  The connection should proceed as normal.
+    #
+    # I think the normal handling for HTTP errors will cover the case
+    # of CONNECT failure.  If not, we can refine the implementation as
+    # needed.
 
     # Some responses are without content by definition
     # FIXME: #12363
@@ -690,7 +715,7 @@
       }
       $request->[REQ_STATE] |= RS_DONE;
       $request->remove_timeout();
-      _finish_request($heap, $request, 1);
+      _finish_request($heap, $request);
       return;
     }
     else {
@@ -817,7 +842,7 @@
     not $request->[REQ_STATE] & RS_POSTED
   ) {
     $request->remove_timeout;
-    _finish_request($heap, $request, 1);
+    _finish_request($heap, $request);
   }
 
 # }}} deliver reponse if complete
@@ -891,7 +916,7 @@
 # {{{ _finish_request
 
 sub _finish_request {
-  my ($heap, $request, $wait) = @_;
+  my ($heap, $request) = @_;
 
   my $request_id = $request->ID;
   if (DEBUG) {
@@ -915,31 +940,7 @@
 
   DEBUG and warn "address is $address";
 
-  if ($wait) {
-    # Wait a bit with removing the request, so there's time to receive
-    # the EOF event in case the connection gets closed.
-    # TODO - Inflates the pending request count.  Why do we do this?
-    my $alarm_id = $poe_kernel->delay_set('remove_request', 0.5, $request_id);
-
-    # remove the old timeout first
-    DEBUG and warn "delay_set; now remove_timeout()";
-    $request->remove_timeout();
-    DEBUG and warn "removed timeout; now timer()";
-    $request->timer($alarm_id);
-  }
-  else {
-    # Virtually identical to _remove_request.
-    # TODO - Make a common sub to handle both cases?
-    my $request = delete $heap->{request}->{$request_id};
-    if (defined $request) {
-      DEBUG and warn "I/O: removing request $request_id";
-      $request->remove_timeout();
-      delete $heap->{ext_request_to_int_id}{$request->[REQ_HTTP_REQUEST]};
-      if (my $wheel = $request->wheel) {
-        delete $heap->{wheel_to_request}->{$wheel->ID};
-      }
-    }
-  }
+  return _clear_req_cache( $heap, $request_id );
 }
 
 # }}} _finish_request
@@ -947,6 +948,15 @@
 #{{{ _remove_request
 sub _poco_weeble_remove_request {
   my ($kernel, $heap, $request_id) = @_[KERNEL, HEAP, ARG0];
+
+  return _clear_req_cache( $heap, $request_id );
+}
+#}}} _remove_request
+
+# helper subroutine to remove a request from our caches
+#{{{ _clear_req_cache
+sub _clear_req_cache {
+  my ($heap, $request_id) = @_;
 
   my $request = delete $heap->{request}->{$request_id};
   if (defined $request) {
@@ -957,8 +967,10 @@
       delete $heap->{wheel_to_request}->{$wheel->ID};
     }
   }
-}
-#}}} _remove_request
+
+  return;
+}
+#}}} _clear_req_cache
 
 # Cancel a single request by HTTP::Request object.
 
@@ -1039,7 +1051,7 @@
 
 =head1 VERSION
 
-version 0.910
+version 0.942
 
 =head1 SYNOPSIS
 
@@ -1356,6 +1368,10 @@
 
   my $count = $kernel->call('ua' => 'pending_requests_count');
 
+NOTE: Sometimes the count might not be what you expected, because responses
+are currently in POE's queue and you haven't processed them. This could happen
+if you configure the C<ConnectionManager>'s concurrency to a high enough value.
+
 =head2 cancel
 
 Cancel a specific HTTP request.  Requires a reference to the original
@@ -1518,8 +1534,6 @@
 means to find the remote server's address without having to make an
 additional request.
 
-Patches for IPv6 support are welcome.
-
 =head1 ENVIRONMENT
 
 POE::Component::Client::HTTP uses two standard environment variables:

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=69292&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 Tue Feb 22 01:19:29 2011
@@ -1,6 +1,6 @@
 package POE::Component::Client::HTTP::Request;
 BEGIN {
-  $POE::Component::Client::HTTP::Request::VERSION = '0.910';
+  $POE::Component::Client::HTTP::Request::VERSION = '0.942';
 }
 # vim: ts=2 sw=2 expandtab
 
@@ -27,6 +27,10 @@
 my $request_seq = 0;
 
 use constant DEBUG => 0;
+
+# TODO CONNECT - Add a flag to indicate whether to generate an HTTP
+# CONNECT request for proxying, or to return REQ_HTTP_REQUEST.  Add a
+# method to update that flag.
 
 use constant REQ_ID            =>  0;
 use constant REQ_POSTBACK      =>  1;
@@ -606,7 +610,7 @@
 
 =head1 VERSION
 
-version 0.910
+version 0.942
 
 =head1 SYNOPSIS
 

Modified: branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP/RequestFactory.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP/RequestFactory.pm?rev=69292&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP/RequestFactory.pm (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Component/Client/HTTP/RequestFactory.pm Tue Feb 22 01:19:29 2011
@@ -1,4 +1,7 @@
 package POE::Component::Client::HTTP::RequestFactory;
+BEGIN {
+  $POE::Component::Client::HTTP::RequestFactory::VERSION = '0.942';
+}
 # vim: ts=2 sw=2 expandtab
 
 use strict;
@@ -21,8 +24,6 @@
 use constant DEBUG               => 0;
 use constant DEFAULT_BLOCK_SIZE  => 4096;
 
-our $VERSION = "0.895";
-
 =head1 CONSTRUCTOR
 
 =head2 new
@@ -227,7 +228,6 @@
     and length $http_request->protocol()
   );
 
-
   # Add the User-Agent: header if one isn't included.
   unless (defined $http_request->user_agent()) {
     $http_request->user_agent($self->agent);
@@ -293,6 +293,10 @@
   #
   # RCAPUTO 2006-03-23: We only support http proxying right now.
   # Avoid proxying if this isn't an http request.
+
+  # TODO CONNECT - Create a PCCH::Request object in https-CONNECT mode
+  # if we're using https and there's an appropriate proxy.
+
   my $proxy = $proxy_override;
   if ($http_request->uri->scheme() eq "http") {
     $proxy ||= $self->[FCT_HTTP_PROXY];

Modified: branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Filter/HTTPChunk.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Filter/HTTPChunk.pm?rev=69292&op=diff
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Filter/HTTPChunk.pm (original)
+++ branches/upstream/libpoe-component-client-http-perl/current/lib/POE/Filter/HTTPChunk.pm Tue Feb 22 01:19:29 2011
@@ -1,6 +1,6 @@
 package POE::Filter::HTTPChunk;
 BEGIN {
-  $POE::Filter::HTTPChunk::VERSION = '0.910';
+  $POE::Filter::HTTPChunk::VERSION = '0.942';
 }
 # vim: ts=2 sw=2 expandtab
 
@@ -205,7 +205,7 @@
 
 =head1 VERSION
 
-version 0.910
+version 0.942
 
 =head1 SYNOPSIS
 

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=69292&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 Tue Feb 22 01:19:29 2011
@@ -1,4 +1,7 @@
 package POE::Filter::HTTPHead_Line;
+BEGIN {
+  $POE::Filter::HTTPHead_Line::VERSION = '0.942';
+}
 # vim: ts=2 sw=2 expandtab
 
 use warnings;
@@ -153,6 +156,9 @@
 }
 
 package POE::Filter::HTTPHead;
+BEGIN {
+  $POE::Filter::HTTPHead::VERSION = '0.942';
+}
 use strict;
 
 =head1 NAME
@@ -161,7 +167,7 @@
 
 =head1 VERSION
 
-version 0.910
+version 0.942
 
 =head1 SYNOPSYS
 
@@ -178,9 +184,6 @@
 the other end of a connection as L<POE::Filter::HTTPD>
 
 =cut
-
-use vars qw($VERSION);
-$VERSION = '0.895';
 
 use base qw(POE::Filter::Stackable);
 use POE::Filter::Line;

Added: branches/upstream/libpoe-component-client-http-perl/current/t/60_rt50231_pending.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/t/60_rt50231_pending.t?rev=69292&op=file
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/t/60_rt50231_pending.t (added)
+++ branches/upstream/libpoe-component-client-http-perl/current/t/60_rt50231_pending.t Tue Feb 22 01:19:29 2011
@@ -1,0 +1,136 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use POE qw(
+  Filter::Stream
+  Component::Client::HTTP
+  Component::Client::Keepalive
+);
+use HTTP::Request::Common qw(GET);
+use Test::More;
+use Test::POE::Server::TCP;
+
+plan tests => 2 * 3;
+
+my $data = <<EOF;
+200 OK HTTP/1.1
+Connection: close
+Content-Length: 118
+Content-Type: text/html
+
+<html>
+<head><title>Test Page</title></head>
+<body><p>This page exists to test POE web components.</p></body>
+</html>
+EOF
+
+# limit parallelism to 1 request at a time
+my $pool = POE::Component::Client::Keepalive->new(
+    keep_alive   => 10,    # seconds to keep connections alive
+    max_open     => 1,    # max concurrent connections - total
+    max_per_host => 1,    # max concurrent connections - per host
+    timeout      => 30,    # max time (seconds) to establish a new connection
+);
+
+my $http_alias = 'ua';
+
+POE::Component::Client::HTTP->spawn(
+    Alias             => $http_alias,
+    Timeout           => 30,
+    FollowRedirects   => 1,
+    ConnectionManager => $pool,
+);
+
+POE::Session->create(
+    inline_states => {
+        _start    => \&_start,
+        _response => \&_response,
+        testd_registered => \&testd_reg,
+        testd_client_input => \&testd_input,
+    },
+    heap => {
+        pending_requests => 0,
+    },
+);
+
+POE::Kernel->run;
+
+sub _start {
+    my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
+
+    $_[HEAP]->{testd} = Test::POE::Server::TCP->spawn(
+      filter => POE::Filter::Stream->new,
+      address => 'localhost',
+    );
+
+    return;
+}
+
+sub testd_reg {
+	my ($kernel) = $_[KERNEL];
+
+	for ( 1 .. 2 ) {
+		$kernel->post( $http_alias,
+			request => '_response',
+			GET( "http://localhost:" . $_[HEAP]->{testd}->port . "/test",
+				Connection => 'close' ),
+			$_,
+		);
+
+		$_[HEAP]->{pending_requests}++;
+	}
+
+	return;
+}
+
+sub testd_input {
+  my ($kernel, $heap, $id, $input) = @_[KERNEL, HEAP, ARG0, ARG1];
+
+  $heap->{input_buffer} .= $input;
+  my $buffer = $heap->{input_buffer};
+
+  if ($buffer =~ /^GET \/test/) {
+    pass("got test request");
+    $heap->{input_buffer} = "";
+    $heap->{testd}->send_to_client($id, $data);
+  }
+  else {
+    diag("INPUT: $input");
+    diag("unexpected test");
+  }
+}
+
+sub _response {
+    my ( $heap, $kernel, $request_packet, $response_packet )
+        = @_[ HEAP, KERNEL, ARG0, ARG1 ];
+
+    $heap->{pending_requests}--;
+
+
+    my $request  = $request_packet->[0];
+    my $id       = $request_packet->[1];
+    my $response = $response_packet->[0];
+
+    my $ua_pending     = $kernel->call($http_alias => 'pending_requests_count');
+    my $actual_pending = $heap->{pending_requests};
+    cmp_ok( $ua_pending, '==', $actual_pending, "pending count matches reality for $id" );
+
+    if ( $response->is_success ) {
+        pass("got response data");
+    }
+    else {
+        fail("got response data");
+        diag( ' HTTP Error: '
+            . $response->code . ' '
+            . ( $response->message || '' ) );
+    }
+
+    # lets shut down if its the last response
+    if ( $heap->{pending_requests} == 0 ) {
+	$kernel->call( $http_alias => 'shutdown' );
+	$heap->{testd}->shutdown;
+    }
+
+    return;
+}
+

Added: branches/upstream/libpoe-component-client-http-perl/current/t/60_rt50231_pending_many.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libpoe-component-client-http-perl/current/t/60_rt50231_pending_many.t?rev=69292&op=file
==============================================================================
--- branches/upstream/libpoe-component-client-http-perl/current/t/60_rt50231_pending_many.t (added)
+++ branches/upstream/libpoe-component-client-http-perl/current/t/60_rt50231_pending_many.t Tue Feb 22 01:19:29 2011
@@ -1,0 +1,141 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use POE qw(
+  Filter::Stream
+  Component::Client::HTTP
+  Component::Client::Keepalive
+);
+use HTTP::Request::Common qw(GET);
+use Test::More;
+use Test::POE::Server::TCP;
+
+plan tests => 5 * 3;
+
+my $data = <<EOF;
+200 OK HTTP/1.1
+Connection: close
+Content-Length: 118
+Content-Type: text/html
+
+<html>
+<head><title>Test Page</title></head>
+<body><p>This page exists to test POE web components.</p></body>
+</html>
+EOF
+
+# limit parallelism to 10 requests at a time
+my $pool = POE::Component::Client::Keepalive->new(
+    keep_alive   => 10,    # seconds to keep connections alive
+    max_open     => 10,    # max concurrent connections - total
+    max_per_host => 10,    # max concurrent connections - per host
+    timeout      => 30,    # max time (seconds) to establish a new connection
+);
+
+my $http_alias = 'ua';
+
+POE::Component::Client::HTTP->spawn(
+    Alias             => $http_alias,
+    Timeout           => 30,
+    FollowRedirects   => 1,
+    ConnectionManager => $pool,
+);
+
+POE::Session->create(
+    inline_states => {
+        _start    => \&_start,
+        _response => \&_response,
+        testd_registered => \&testd_reg,
+        testd_client_input => \&testd_input,
+    },
+    heap => {
+        pending_requests => 0,
+    },
+);
+
+POE::Kernel->run;
+
+sub _start {
+    my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
+
+    $_[HEAP]->{testd} = Test::POE::Server::TCP->spawn(
+      filter => POE::Filter::Stream->new,
+      address => 'localhost',
+    );
+
+    return;
+}
+
+sub testd_reg {
+	my ($kernel) = $_[KERNEL];
+
+	for ( 1 .. 5 ) {
+		$kernel->post( $http_alias,
+			request => '_response',
+			GET( "http://localhost:" . $_[HEAP]->{testd}->port . "/test",
+				Connection => 'close' ),
+			$_,
+		);
+
+		$_[HEAP]->{pending_requests}++;
+	}
+
+	return;
+}
+
+sub testd_input {
+  my ($kernel, $heap, $id, $input) = @_[KERNEL, HEAP, ARG0, ARG1];
+
+  $heap->{input_buffer} .= $input;
+  my $buffer = $heap->{input_buffer};
+
+  if ($buffer =~ /^GET \/test/) {
+    pass("got test request");
+    $heap->{input_buffer} = "";
+    $heap->{testd}->send_to_client($id, $data);
+  }
+  else {
+    diag("INPUT: $input");
+    diag("unexpected test");
+  }
+}
+
+sub _response {
+    my ( $heap, $kernel, $request_packet, $response_packet )
+        = @_[ HEAP, KERNEL, ARG0, ARG1 ];
+
+    $heap->{pending_requests}--;
+
+
+    my $request  = $request_packet->[0];
+    my $id       = $request_packet->[1];
+    my $response = $response_packet->[0];
+
+    my $ua_pending     = $kernel->call($http_alias => 'pending_requests_count');
+    my $actual_pending = $heap->{pending_requests};
+    TODO: {
+      # TODO Generally the count matches up, but sometimes we're off by 1 because it's still in the POE queue
+      # Nothing much we can do, this test is here just for kicks, really...
+      local $TODO = "Setting parallelism screws with timing";
+      cmp_ok( $ua_pending, '==', $actual_pending, "pending count matches reality for $id" );
+    };
+
+    if ( $response->is_success ) {
+        pass("got response data");
+    }
+    else {
+        fail("got response data");
+        diag( ' HTTP Error: '
+            . $response->code . ' '
+            . ( $response->message || '' ) );
+    }
+
+    # lets shut down if its the last response
+    if ( $heap->{pending_requests} == 0 ) {
+	$kernel->call( $http_alias => 'shutdown' );
+	$heap->{testd}->shutdown;
+    }
+
+    return;
+}
+




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