/usr/share/perl5/Plack/Middleware/RearrangeHeaders.pm is in libplack-perl 0.9985-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 | package Plack::Middleware::RearrangeHeaders;
use strict;
use warnings;
use parent qw( Plack::Middleware );
use HTTP::Headers;
sub call {
my $self = shift;
my $res = $self->app->(@_);
$self->response_cb($res, sub {
my $res = shift;
my $h = HTTP::Headers->new(@{$res->[1]});
my @new_headers;
$h->scan(sub { push @new_headers, @_ });
$res->[1] = \@new_headers;
});
}
1;
__END__
=head1 NAME
Plack::Middleware::RearrangeHeaders - Reorder HTTP headers for buggy clients
=head1 SYNOPSIS
use Plack::Builder;
my $app = sub {
return [ 200, [
'Last-Modified' => 'Wed, 23 Sep 2009 13:36:33 GMT',
'Content-Type' => 'text/plain',
'ETag' => 'foo bar',
], [ 'Hello Foo' ] ];
};
builder {
enable "Plack::Middleware::RearrangeHeaders";
$app;
};
=head1 DESCRIPTION
Plack::Middleware::RearrangeHeaders sorts HTTP headers based on "Good Practice" i.e.:
# "Good Practice" order of HTTP message headers:
# - Response-Headers
# - Entity-Headers
to work around buggy clients like very old MSIE or broken HTTP proxy
servers. Most clients today don't (and shouldn't) care about HTTP
header order but if you're too pedantic or have some environments
where you need to deal with buggy clients like above, this might be
useful.
=head1 AUTHOR
Tatsuhiko Miyagawa
=head1 SEE ALSO
L<HTTP::Headers>
=cut
|