Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes "Not an ARRAY reference at Plack-Middleware-Header/lib/Plack/Mi…

…ddleware/Header.pm line 18"
  • Loading branch information...
commit 781ab06e571fa5ace0c8a2a2d6ca22138ca4cc52 1 parent 613fa88
@oalders authored
Showing with 22 additions and 16 deletions.
  1. +22 −16 lib/Plack/Middleware/Header.pm
View
38 lib/Plack/Middleware/Header.pm
@@ -11,22 +11,28 @@ use Plack::Util;
our $VERSION = '0.03';
sub call {
- my($self, $env) = @_;
-
- my $res = $self->app->($env);
-
- my $headers = $res->[1];
- if ( $self->set ) {
- Plack::Util::header_iter($self->set, sub {Plack::Util::header_set($headers, @_)});
- }
- if ( $self->append ) {
- push @$headers, @{$self->append};
- }
- if ( $self->unset ) {
- Plack::Util::header_remove($headers, $_) for @{$self->unset};
- }
-
- return $res;
+ my $self = shift;
+ my $res = $self->app->(@_);
+
+ $self->response_cb(
+ $res,
+ sub {
+ my $res = shift;
+ my $headers = $res->[1];
+
+ if ( $self->set ) {
+ Plack::Util::header_iter($self->set, sub {Plack::Util::header_set($headers, @_)});
+ }
+ if ( $self->append ) {
+ my $headers = $res->[1];
+ push @$headers, @{$self->append};
+ }
+ if ( $self->unset ) {
+ my $headers = $res->[1];
+ Plack::Util::header_remove($headers, $_) for @{$self->unset};
+ }
+ }
+ );
}
1;
Please sign in to comment.
Something went wrong with that request. Please try again.