Commit 8d59dd6f authored by tufengqi's avatar tufengqi

新增TPHPSTEAM自定义类

parent 84c265e4
......@@ -44,20 +44,32 @@ class TPhpStream extends TTransport
private $write_ = false;
private static $fd;
public function __construct($mode)
{
$this->read_ = $mode & self::MODE_R;
$this->write_ = $mode & self::MODE_W;
}
public function setContent($HTTP_RAW_POST_DATA){
public static function getFd()
{
return self::$fd;
}
public static function setFd($fd)
{
self::$fd = $fd;
}
public function open()
{
if ($this->read_ && !defined('IS_SWOOLE_SERVICE')) {
$this->inStream_ = @fopen(self::inStreamName(), 'r');
if ($this->read_) {
if (defined('IS_SWOOLE_SERVICE') && true === IS_SWOOLE_SERVICE) {
$this->inStream_ = self::$fd;
} else {
$this->inStream_ = @fopen(self::inStreamName(), 'r');
}
if (!is_resource($this->inStream_)) {
throw new TException('TPhpStream: Could not open php://input');
}
......@@ -72,7 +84,7 @@ class TPhpStream extends TTransport
public function close()
{
if ($this->read_ && !defined('IS_SWOOLE_SERVICE')) {
if ($this->read_) {
@fclose($this->inStream_);
$this->inStream_ = null;
}
......@@ -89,9 +101,6 @@ class TPhpStream extends TTransport
public function read($len)
{
if (defined('IS_SWOOLE_SERVICE') && true === IS_SWOOLE_SERVICE) {
subStr();
}
$data = @fread($this->inStream_, $len);
if ($data === false || $data === '') {
throw new TException('TPhpStream: Could not read ' . $len . ' bytes');
......@@ -121,9 +130,11 @@ class TPhpStream extends TTransport
private static function inStreamName()
{
if (php_sapi_name() == 'cli') {
if (defined('IS_SWOOLE_SERVICE') && true === IS_SWOOLE_SERVICE) {
return 'php://temp';
}
return 'php://stdin';
}
return 'php://input';
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment