From: David Reiss Date: Thu, 26 Mar 2009 06:14:45 +0000 (+0000) Subject: THRIFT-404. php: Make TPhpStream work for cli (cgi) scripts X-Git-Tag: 0.2.0~213 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=be648eee8c120b64d6a2dd1d1faa62dbf0ba72b2;p=common%2Fthrift.git THRIFT-404. php: Make TPhpStream work for cli (cgi) scripts git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@758526 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/php/src/transport/TPhpStream.php b/lib/php/src/transport/TPhpStream.php index 9a3049a7..9b8de828 100644 --- a/lib/php/src/transport/TPhpStream.php +++ b/lib/php/src/transport/TPhpStream.php @@ -36,7 +36,7 @@ class TPhpStream extends TTransport { public function open() { if ($this->read_) { - $this->inStream_ = @fopen('php://input', 'r'); + $this->inStream_ = @fopen(self::inStreamName(), 'r'); if (!is_resource($this->inStream_)) { throw new TException('TPhpStream: Could not open php://input'); } @@ -88,6 +88,13 @@ class TPhpStream extends TTransport { @fflush($this->outStream_); } + private static function inStreamName() { + if (php_sapi_name() == 'cli') { + return 'php://stdin'; + } + return 'php://input'; + } + } ?>