Permalink
Browse files

Applied a patch to Filter::HTTPD from Maciej Pijanka (agaran). Create…

…d applicable regression test.
  • Loading branch information...
1 parent 7057981 commit c47d4a5ad10d4fd91350557b7dc0bb1a6c76d4c7 @bingos bingos committed Feb 18, 2008
Showing with 85 additions and 1 deletion.
  1. +1 −0 MANIFEST
  2. +5 −1 lib/POE/Filter/HTTPD.pm
  3. +79 −0 t/90_regression/agaran-filter-httpd.t
View
@@ -153,6 +153,7 @@ t/30_loops/00_base/wheel_sf_tcp.pm
t/30_loops/00_base/wheel_sf_udp.pm
t/30_loops/00_base/wheel_sf_unix.pm
t/30_loops/00_base/wheel_tail.pm
+t/90_regression/agaran-filter-httpd.t
t/90_regression/averell-callback-ret.t
t/90_regression/bingos-followtail.t
t/90_regression/broeren-win32-nbio.t
@@ -175,7 +175,11 @@ sub get {
# Use the request line to create a request object.
- my $r = HTTP::Request->new($1, URI->new($2));
+ my $method = $1;
+ my $req_path = $2;
+ $req_path =~ s/^[\/]{2,}/\//; # fix double slash starting path
+
+ my $r = HTTP::Request->new($method, URI->new($req_path));
$r->protocol($proto);
$self->[CLIENT_PROTO] = $proto = _http_version($proto);
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+# $Id: cfedde-filter-httpd.t 2206 2007-07-25 04:44:21Z rcaputo $
+# vim: filetype=perl
+
+use warnings;
+use strict;
+
+BEGIN {
+ eval "use HTTP::Request";
+ if ($@) {
+ print "1..0 # skip - HTTP::Request needed to test POE::Filter::HTTPD\n";
+ exit;
+ }
+}
+
+use Test::More tests => 3;
+
+my $port;
+
+use POE qw(
+ Component::Client::TCP
+ Component::Server::TCP
+ Filter::HTTPD
+);
+
+#
+# handler
+#
+
+POE::Component::Server::TCP->new(
+ Port => 0,
+ ClientFilter => 'POE::Filter::HTTPD',
+ Started => sub {
+ use Socket qw(sockaddr_in);
+ $port = (
+ sockaddr_in($_[HEAP]->{listener}->getsockname())
+ )[0];
+ },
+
+ ClientInput => sub {
+ my ( $kernel, $heap, $request ) = @_[ KERNEL, HEAP, ARG0 ];
+ isa_ok( $request, 'HTTP::Message', $request);
+ ok( $request->uri() eq '/foo/bar', 'Double striped' );
+ },
+);
+
+POE::Component::Client::TCP->new (
+ RemoteAddress => '127.0.0.1',
+ RemotePort => $port,
+ ServerInput => sub {
+ diag("Server Input: $_[ARG0]");
+ }
+);
+
+POE::Component::Client::TCP->new (
+ RemoteAddress => '127.0.0.1',
+ RemotePort => $port,
+ Connected => sub {
+ ok 1, 'client connected';
+ $_[HEAP]->{server}->put( "GET //foo/bar 1.0\015\012\015\012");
+ },
+ ServerInput => sub {
+ ok 1, "client got $_[ARG0]";
+ }
+);
+
+POE::Session->create(
+ inline_states => {
+ _start => sub {
+ $_[KERNEL]->delay_add( done => 3 );
+ },
+ done => sub {
+ exit 1;
+ }
+ }
+);
+
+$poe_kernel->run();
+exit 0;

0 comments on commit c47d4a5

Please sign in to comment.