/usr/share/perl5/Plack/Middleware/Header.pm is in libplack-middleware-header-perl 0.04-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | package Plack::Middleware::Header;
use strict;
use 5.008_001;
use parent qw(Plack::Middleware);
__PACKAGE__->mk_accessors(qw(set append unset));
use Plack::Util;
our $VERSION = '0.04';
sub call {
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 ) {
push @$headers, @{$self->append};
}
if ( $self->unset ) {
Plack::Util::header_remove($headers, $_) for @{$self->unset};
}
}
);
}
1;
__END__
=head1 NAME
Plack::Middleware::Header - modify HTTP response headers
=head1 SYNOPSIS
use Plack::Builder;
my $app = sub {['200', [], ['hello']]};
builder {
enable 'Header',
set => ['X-Plack-One' => '1'],
append => ['X-Plack-Two' => '2'],
unset => ['X-Plack-Three'];
$app;
};
=head1 DESCRIPTION
Plack::Middleware::Header
=head1 AUTHOR
Masahiro Chiba
=head1 LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 SEE ALSO
L<Plack::Middleware> L<Plack::Builder>
=cut
|