CC: | miyagawa [...] bulknews.net |
Subject: | wish: consider refactoring 'read_from_stdin' to make it easier to swap out STDIN |
Currently, 'CGI::read_from_stdin()' contains this code:
if ( $MOD_PERL ) {
$res = $self->r->read($tempbuf, $bufsiz, 0)
}
else {
$res = read(\*STDIN, $tempbuf, $bufsiz);
}
###
Then CGI::PSGI came along and wanted to read from a source other than
these two. So, it overloads 'read_from_stdin()' to essentially change
one line:
$res = $self->{psgi_env}{'psgi.input'}->read($tempbuf, $bufsiz, 0);
But now we've found a bug in 'read_from_stdin()', so we have some
changes to it in 'git' (currently just in Yanick's branch), Once
released, CGI::PSGI will need to be patched as well (and any other
module that takes the same approach).
My proposal is to to make a routine that encapsulates the if/else logic
above.
Then, CGI::PSGI could override just that. Also, it's step towards
further isolating mod_perl-specific logic in CGI.pm.