Re: Reading STDIN on POST queries?
| From: | Jeff P | Date: | Thu, 04 Jan 2001 23:24:11 +0000 |
| Subject: | Re: Reading STDIN on POST queries? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-32766@lists.php.net to get a copy of this message | ||
> Use the constants describe in http://php.net/fopen
> Or... Hmm, maybe you are asking about $REQUEST_URI?...
> Look at the output from <?php phpinfo();?> and see if the data you want is
> there.
Alas, this doesn't seem to work.
The problem, best I can tell, is that PHP is
parsing STDIN (ie, where Apache sends the data
from the POST connection) before parsing and
running the PHP script. The POST data isn't part
of the URI (that'd be GET), and phpinfo() doesn't
seem to report what raw data might have existed on
STDIN.
Ethereal (network sniffer) shows that the data is
indeed being sent to Apache. Writing a quick perl
script that reads STDIN shows that the data is
being sent to the execed CGI process properly.
Within the PHP script, a call to fopen with either
/dev/stdin or php://stdin succeeds, and feof()
returns false (meaning not at end of file yet;
or more precisely, that the pointer into the
file's buffer hasn't attempted to read past the
end of the file). fread at this point returns
nothing, and feof() will then return true (ie, eof
reached).
Still scratching my head... ??
best,
Jeff
> > Is there a way to read STDIN directly (ie, without
> > having PHP 4.0.4 parsing it for encoded
> > variable/value pairs) in a cgi-based install of
> > PHP?