Make the HTTP engine use before instead of around to wrap {prepare,finalize}_read.
Florian Ragwitz [Thu, 11 Sep 2008 21:31:02 +0000 (21:31 +0000)]
This makes the http engine tests pass again.

Still I have no idea why

around foo => sub {
shift->(@_);
};

isn't the same as

around foo => sub {
my $orig = shift;
$orig->(@_);
};

The first version will also pass the coderef to the original method.

lib/Catalyst/Engine/HTTP.pm

index 7e6beb1..0dfc8e3 100644 (file)
@@ -84,21 +84,19 @@ sub finalize_headers {
 
 =cut
 
-around finalize_read => sub {
+before finalize_read => sub {
     # Never ever remove this, it would result in random length output
     # streams if STDIN eq STDOUT (like in the HTTP engine)
     *STDIN->blocking(1);
-    shift->(@_);
 };
 
 =head2 $self->prepare_read($c)
 
 =cut
 
-around prepare_read => sub {
+before prepare_read => sub {
     # Set the input handle to non-blocking
     *STDIN->blocking(0);
-    shift->(@_);
 };
 
 =head2 $self->read_chunk($c, $buffer, $length)