CGI-Emulate-PSGI-Streaming

 view release on metacpan or  search on metacpan

lib/CGI/Parse/PSGI/Streaming.pm  view on Meta::CPAN

    my $writer; # the writer object returned by the responder

    ## no critic(ProhibitTies)
    tie *{$output},'CGI::Parse::PSGI::Streaming::Handle', sub {
        # this callback is invoked with whatever bytes were printed to
        # the filehandle; it will be called with no argument (or an
        # undef) when the filehandle is closed
        my ($data) = @_;

        # reset the default filehandle to the real STDOUT, just in
        # case: it's nice to make sure all the callbacks are invoked
        # with the state they expect
        my $saver = SelectSaver->new("::STDOUT");

        # if we're still parsing the headers
        if (!$response) {
            if (defined $data) {
                $headers .= $data;
            }
            else { # closed file before the end of headers
                $headers = "HTTP/1.1 500 Internal Server Error\x0d\x0a";



( run in 0.713 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )