You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by dr...@apache.org on 2009/03/26 07:14:47 UTC

svn commit: r758526 - /incubator/thrift/trunk/lib/php/src/transport/TPhpStream.php

Author: dreiss
Date: Thu Mar 26 06:14:45 2009
New Revision: 758526

URL: http://svn.apache.org/viewvc?rev=758526&view=rev
Log:
THRIFT-404. php: Make TPhpStream work for cli (cgi) scripts

Modified:
    incubator/thrift/trunk/lib/php/src/transport/TPhpStream.php

Modified: incubator/thrift/trunk/lib/php/src/transport/TPhpStream.php
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/php/src/transport/TPhpStream.php?rev=758526&r1=758525&r2=758526&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/php/src/transport/TPhpStream.php (original)
+++ incubator/thrift/trunk/lib/php/src/transport/TPhpStream.php Thu Mar 26 06:14:45 2009
@@ -36,7 +36,7 @@
 
   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 @@
     @fflush($this->outStream_);
   }
 
+  private static function inStreamName() {
+    if (php_sapi_name() == 'cli') {
+      return 'php://stdin';
+    }
+    return 'php://input';
+  }
+
 }
 
 ?>