/usr/share/perl5/Plack/Middleware/Chunked.pm is in libplack-perl 1.0033-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 | package Plack::Middleware::Chunked;
use strict;
use parent qw(Plack::Middleware);
use Plack::Util;
sub call {
my($self, $env) = @_;
my $res = $self->app->($env);
$self->response_cb($res, sub {
my $res = shift;
my $h = Plack::Util::headers($res->[1]);
if ($env->{'SERVER_PROTOCOL'} ne 'HTTP/1.0' and
! Plack::Util::status_with_no_entity_body($res->[0]) and
! $h->exists('Content-Length') and
! $h->exists('Transfer-Encoding')
) {
$h->set('Transfer-Encoding' => 'chunked');
my $done;
return sub {
my $chunk = shift;
return if $done;
unless (defined $chunk) {
$done = 1;
return "0\015\012\015\012";
}
return '' unless length $chunk;
return sprintf('%x', length $chunk) . "\015\012$chunk\015\012";
};
}
});
}
1;
__END__
=head1 NAME
Plack::Middleware::Chunked - Applies chunked encoding to the response body
=head1 SYNOPSIS
# Mostly from server implemenations
$app = Plack::Middeware::Chunked->wrap($app);
=head1 DESCRIPTION
Plack::Middeware::Chunked is a middleware, or rather a library for
PSGI server to automatically add chunked encoding to the response body
when Content-Length is not set in the response header.
=head1 AUTHOR
Tatsuhiko Miyagawa
=head1 SEE ALSO
Rack::Chunked
=cut
|