This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
To: <modperl@apache.org> From: "Rodney Broom" <rbroom@Desert.NET> Subject: Re: Resetting STDIN after r->read Date: Fri, 8 Jun 2001 15:53:03 -0700 From: rodney Broom <rbroom@Desert.NET> > I've got this module that needs to redirect sometimes. In doing this, the > next request misses any POST data. I was playing with saving the data to > disk and then reloading it on the next request like this: > > if ($first_pass) { > $r->read($data, ...); > print TEMP_FILE, $data; > return REDIRECT; > } > else { > open(STDIN, "<$temp_file"); > $r->subprocess_env(CONTENT_LENGTH => -s $temp_file); > } > > The idea here is that normal packages like CGI won't have to know what's up > and my programmers won't have to work around this. But, when I get to the > script, STDIN is empty. Ay thouhts about how to handle this? > OK, here's what the solution was. According to Doug in a posting that I found in an archive search, mod_perl's STDIN is really just a Perl glob, and not a file handle. So instead of reading from it (and thereby emptying the file handle named STDIN so that CGI and other things can't get this data), now I simply assign from it: if ($first_pass) { print TEMP_FILE, $STDIN; return REDIRECT; } else { read(TEMP_FILE, my $buf, (-s $temp_file)) $STDIN = $buf; $r->subprocess_env(CONTENT_LENGTH => -s $temp_file); } I'm obviously doing a lot more testing than that, but this is the jist. ===