Read request body from the file given in REQUEST_BODY_FILE parameter
@return boolean Success
772648
public function readBodyFile()
    {
        if (!isset($this->attrs->server['REQUEST_BODY_FILE'])) {
            return false;
        }

        FileSystem::readfileChunked(
            $this->attrs->server['REQUEST_BODY_FILE'],
            function ($file, $success) {
                $this->attrs->inputDone = true;
                if ($this->sleepTime === 0) {
                    $this->wakeup();
                }
            },
            function ($file, $chunk) {
                // readed chunk
                $this->stdin($chunk);
            }
        );

        return true;
    }
730120
private function readBody()
	{
		$body= '';

		while( !feof($this->handle) )
		{
			$body.= fgets($this->handle);
		}

		if( isset( $this->headers['Transfer-Encoding'] ) && $this->headers['Transfer-Encoding']==='chunked' )
		{
			$this->body= $this->unchunk( $body );
		}else{
			$this->body= $body;
		}
	}
716254
public function read()
    {
        $result = '';
        $ht = $this->getHTaccessFilename();
        $fs = $this->getFilesystem();
        if (@$fs->isFile($ht)) {
            $result = @$fs->get($ht);
            if ($result === false) {
                throw new Exception("Failed to read from file $ht");
            }
        }

        return $result;
    }
954426
public function getBody()
    {
        $doc = $this->getDocument();
        if (!$doc) {
            return false;
        }

        $body = $doc->getElementsByTagName('body');
        if (!$body->length) {
            return false;
        }

        return $body->item(0);
    }
1149947
public function getContent()
    {
        if (empty($this->content)) {
            $requestBody = file_get_contents('php://input');
            if (strlen($requestBody) > 0) {
                $this->content = $requestBody;
            }
        }

        return $this->content;
    }
1086752
public function read()
	{
		$this->position++;
		if ( $this->position >= count( $this->buffer ) ) return false;

		return $this->buffer[ $this->position ];
	}
544926
private function getInputFromHTTP() {
		if($this->logger) $this->logger->debug('Getting and decoding HTTP request body');
		$input = file_get_contents('php://input');
		$this->setInput($input);
		return $this->input;
	}
268863
def read_request(file_name, **params):
    
    with open(file_name, 'r') as f:
        data = f.read()
        return read_request_from_str(data, **params)
1038166
protected function readFile()
    {
        $file = $this->getFile();
        $raw = $this->ioHelper->getFileContents($file);
        return $this->jsonHelper->decode($raw);
    }
147485
public function read()
    {
        $filename = $this->filename;
//        if (!$this->isFileWritable() && file_exists($this->getCacheFilename())) {
//            $filename = $this->getCacheFilename();
//        }

        $ret = Yaml::parse(file_get_contents($filename));
        if (false === $ret || array() === $ret) {
            throw new \InvalidArgumentException(sprintf('The %s file is not valid.', $filename));
        }

        if (count($ret)) {
            return $ret;
        } else {
            return array();
        }
    }
171505
protected function readFromHttpData()
    {
        // Check validity of the uploaded files
        $aTempFiles = [];
        foreach($_FILES as $sVarName => $aFile)
        {
            if(is_array($aFile['name']))
            {
                $nFileCount = count($aFile['name']);
                for($i = 0; $i < $nFileCount; $i++)
                {
                    if(!$aFile['name'][$i])
                    {
                        continue;
                    }
                    if(!array_key_exists($sVarName, $aTempFiles))
                    {
                        $aTempFiles[$sVarName] = [];
                    }
                    // Filename without the extension
                    $sFilename = $this->filterFilename(pathinfo($aFile['name'][$i], PATHINFO_FILENAME), $sVarName);
                    // Copy the file data into the local array
                    $aTempFiles[$sVarName][] = [
                        'name' => $aFile['name'][$i],
                        'type' => $aFile['type'][$i],
                        'tmp_name' => $aFile['tmp_name'][$i],
                        'error' => $aFile['error'][$i],
                        'size' => $aFile['size'][$i],
                        'filename' => $sFilename,
                        'extension' => pathinfo($aFile['name'][$i], PATHINFO_EXTENSION),
                    ];
                }
            }
            else
            {
                if(!$aFile['name'])
                {
                    continue;
                }
                if(!array_key_exists($sVarName, $aTempFiles))
                {
                    $aTempFiles[$sVarName] = [];
                }
                // Filename without the extension
                $sFilename = $this->filterFilename(pathinfo($aFile['name'], PATHINFO_FILENAME), $sVarName);
                // Copy the file data into the local array
                $aTempFiles[$sVarName][] = [
                    'name' => $aFile['name'],
                    'type' => $aFile['type'],
                    'tmp_name' => $aFile['tmp_name'],
                    'error' => $aFile['error'],
                    'size' => $aFile['size'],
                    'filename' => $sFilename,
                    'extension' => pathinfo($aFile['name'], PATHINFO_EXTENSION),
                ];
            }
        }

        // Check uploaded files validity
        foreach($aTempFiles as $sVarName => $aFiles)
        {
            foreach($aFiles as $aFile)
            {
                // Verify upload result
                if($aFile['error'] != 0)
                {
                    throw new \Jaxon\Exception\Error($this->trans('errors.upload.failed', $aFile));
                }
                // Verify file validity (format, size)
                if(!$this->validateUploadedFile($sVarName, $aFile))
                {
                    throw new \Jaxon\Exception\Error($this->getValidatorMessage());
                }
                // Get the path to the upload dir
                $this->getUploadDir($sVarName);
            }
        }

        // Copy the uploaded files from the temp dir to the user dir
        foreach($aTempFiles as $sVarName => $aTempFiles)
        {
            $this->aUserFiles[$sVarName] = [];
            foreach($aTempFiles as $aFile)
            {
                // Get the path to the upload dir
                $sUploadDir = $this->getUploadDir($sVarName);
                // Set the user file data
                $xUploadedFile = UploadedFile::fromHttpData($sUploadDir, $aFile);
                // All's right, move the file to the user dir.
                move_uploaded_file($aFile["tmp_name"], $xUploadedFile->path());
                $this->aUserFiles[$sVarName][] = $xUploadedFile;
            }
        }
    }
1288725
private function getRequest()
    {
        $error = null;

        do {
            if (array_key_exists('REQUEST_METHOD', $_SERVER) && $_SERVER['REQUEST_METHOD'] != 'POST') {
                $error = self::INVALIDREQUEST;
                break;
            };

            $request = !empty($_GET['rawRequest']) ? $_GET['rawRequest'] : file_get_contents('php://input');
            $this->request = json_decode($request, false);
            if ($this->request === null) {
                $error = self::PARSEERROR;
                break;
            }

            if ($this->request === []) {
                $error = self::INVALIDREQUEST;
                break;
            }

            // check for batch call
            if (is_array($this->request)) {
                if (count($this->request) > $this->MaxBatchCalls) {
                    $error = self::INVALIDREQUEST;
                    break;
                }

                $this->calls = $this->request;
                $this->isBatchCall = true;
            } else {
                $this->calls[] = $this->request;
            }
        } while (false);

        return $error;
    }
722914
public function load_file()
	{
		$args = func_get_args();
		$this->load(call_user_func_array('file_get_contents', $args), true);
		// Throw an error if we can't properly load the dom.
		if (($error=error_get_last())!==null) {
			$this->clear();
			return false;
		}
	}
774461
public function read()
    {
        // First, read headers only
        $response = '';
        $gotStatus = false;
        while ($line = @fgets($this->socket)) {
            $gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false);
            if ($gotStatus) {
                $response .= $line;
                if (!chop($line)) { break;
                }
            }
        }

        $statusCode = Zend_Http_Response::extractCode($response);
         
        // Handle 100 and 101 responses internally by restarting the read again
        if ($statusCode == 100 || $statusCode == 101) { return $this->read();
        }

        /**
         * Responses to HEAD requests and 204 or 304 responses are not expected
         * to have a body - stop reading here
         */
        if ($statusCode == 304 || $statusCode == 204  
            || $this->method == Zend_Http_Client::HEAD
        ) { return $response;
        }

        // Check headers to see what kind of connection / transfer encoding we have
        $headers = Zend_Http_Response::extractHeaders($response);

        // if the connection is set to close, just read until socket closes
        if (isset($headers['connection']) && $headers['connection'] == 'close') {
            while ($buff = @fread($this->socket, 8192)) {
                $response .= $buff;
            }

            $this->close();

            // Else, if we got a transfer-encoding header (chunked body)
        } elseif (isset($headers['transfer-encoding'])) {
            if ($headers['transfer-encoding'] == 'chunked') {
                do {
                    $chunk = '';
                    $line = @fgets($this->socket);
                    $chunk .= $line;

                    $hexchunksize = ltrim(chop($line), '0');
                    $hexchunksize = strlen($hexchunksize) ? strtolower($hexchunksize) : 0;

                    $chunksize = hexdec(chop($line));
                    if (dechex($chunksize) != $hexchunksize) {
                        @fclose($this->socket);
                        include_once 'Zend/Http/Client/Adapter/Exception.php';
                        throw new Zend_Http_Client_Adapter_Exception(
                            'Invalid chunk size "' .
                            $hexchunksize . '" unable to read chunked body'
                        );
                    }

                    $left_to_read = $chunksize;
                    while ($left_to_read > 0) {
                        $line = @fread($this->socket, $left_to_read);
                        $chunk .= $line;
                        $left_to_read -= strlen($line);
                    }

                    $chunk .= @fgets($this->socket);
                    $response .= $chunk;
                } while ($chunksize > 0);
            } else {
                throw new Zend_Http_Client_Adapter_Exception(
                    'Cannot handle "' .
                    $headers['transfer-encoding'] . '" transfer encoding'
                );
            }

            // Else, if we got the content-length header, read this number of bytes
        } elseif (isset($headers['content-length'])) {
            $left_to_read = $headers['content-length'];
            $chunk = '';
            while ($left_to_read > 0) {
                $chunk = @fread($this->socket, $left_to_read);
                $left_to_read -= strlen($chunk);
                $response .= $chunk;
            }
        
            // Fallback: just read the response (should not happen)
        } else {
            while ($buff = @fread($this->socket, 8192)) {
                $response .= $buff;
            }

            $this->close();
        }

        return $response;
    }
1233379
private function parseUploadedFiles(Request $request)
    {
        $bodyParams = $request->all();
        if (!isset($bodyParams['map'])) {
            throw new RequestError('The request must define a `map`');
        }

        $map = json_decode($bodyParams['map'], true);
        $result = json_decode($bodyParams['operations'], true);
        if (isset($result['operationName'])) {
            $result['operation'] = $result['operationName'];
            unset($result['operationName']);
        }

        foreach ($map as $fileKey => $locations) {
            foreach ($locations as $location) {
                $items = &$result;
                foreach (explode('.', $location) as $key) {
                    if (!isset($items[$key]) || !is_array($items[$key])) {
                        $items[$key] = [];
                    }
                    $items = &$items[$key];
                }

                $items = $request->allFiles()[$fileKey];
            }
        }

        $request->replace($result);

        return $request;
    }
230218
public function processRequest()
    {
        if(!$this->canProcessRequest())
        {
            return false;
        }
        if(count($_FILES) > 0)
        {
            $this->readFromHttpData();
        }
        elseif(($this->sTempFile))
        {
            $this->readFromTempFile();
        }
        return true;
    }
296202
public function getBody()
    {
        // If this value has been read from the stream, retrieve it from storage
        if (null !== $this->input[self::INPUT_METHOD_BODY]) {
            return $this->input[self::INPUT_METHOD_BODY];
        }

        if (is_resource($this->stream) && 'stream' === get_resource_type($this->stream)) {
            $streamData = stream_get_contents($this->stream);
        } elseif (is_string($this->stream)) {
            $stream = @fopen($this->stream, "r");

            if (false === $stream) {
                throw new InternalErrorException('Unable to open request input stream.');
            }

            $streamData = stream_get_contents($stream);

            fclose($stream);
        } else {
            $streamData = false;
        }

        if (false === $streamData) {
            throw new InternalErrorException('Unable to open request input stream.');
        }

        $this->input[self::INPUT_METHOD_BODY] = $streamData;

        return $this->input[self::INPUT_METHOD_BODY];
    }