NAME

CGI::Parse::PSGI::Streaming - creates a filehandle that parses CGI output and writes to a PSGI responder

VERSION

version 1.0.1

SYNOPSIS

use CGI::PSGI;
use CGI::Parse::PSGI::Streaming;

sub {
  my ($env) = @_;

  my $q = CGI::PSGI->new($env);

  return sub {
    my ($psgi_responder) = @_;

    my $tied_stdout =
      CGI::Parse::PSGI::Streaming::parse_cgi_output_streaming_fh(
        $psgi_responder,
      );

    select $tied_stdout;
    old_sub_that_expects_a_cgi_object_and_prints($q);
    close $tied_stdout;
  };
 };

DESCRIPTION

You should probably not do what the "synopsis" says, and just use CGI::Emulate::PSGI::Streaming directly.

FUNCTIONS

parse_cgi_output_streaming_fh

my $tied_stdout =
  CGI::Parse::PSGI::Streaming::parse_cgi_output_streaming_fh(
    $psgi_responder,
  );

This function, given a PSGI responder object, builds a tied filehandle that your old CGI code can print to.

The tied handle will parse CGI headers, and pass them on to the responder in the format that it expects them. The handle will then feed whatever is printed to it, on to the writer object that the responder returned. See the "Delayed Response and Streaming Body" section of the PSGI spec for details.

AUTHOR

Gianni Ceccarelli <gianni.ceccarelli@broadbean.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Broadbean.com.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.