Yes, that would close the filehandle before the file was sent, so no file would be sent
See Re^2: plack: close filehandle responsibility (everybody), while https://metacpan.org/pod/Plack::Response#body doesn't document that it closes $io the handle it accepts as argument, it does do it
Try it out, fireup this plack program, and start taskmanager, and watch the handles count not increase with each browser request you make
#!/usr/bin/perl -- use strict; use warnings; use Plack::Builder; use Path::Tiny qw/ path /; my $app = sub { return [ 200, [ 'Content-Type' => 'text/plain; charset=UTF-8', ], path( __FILE__ )->openr_raw, ]; }; my $finalapp = builder { enable 'StackTrace'; $app; }; if( $0 eq __FILE__ ){ require Plack::Runner; my $runner = Plack::Runner->new; $runner->parse_options( qw' --host 127.0.0.1 --port 5000 ' ); $runner->run( $finalapp ); ## perl this.psgi } else { $finalapp; ## plackup -l localhost:5000 this.psgi } ## lwp-request -Ed http://127.0.0.1:5000/
If I close the handle openr_raw returns before Plack reads it without slurping, there will probably be a plack error
update: I just tested it, no error, but no file is sent either as expected
In reply to Re^2: plack: close filehandle responsibility
by Anonymous Monk
in thread [solved] plack: close filehandle responsibility
by basiliscos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |