From be648eee8c120b64d6a2dd1d1faa62dbf0ba72b2 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Thu, 26 Mar 2009 06:14:45 +0000 Subject: [PATCH] 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 --- lib/php/src/transport/TPhpStream.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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'; + } + } ?> -- 2.17.1