lib/Dropbox/Client.php
private static function readFully($inStream, $numBytes)
    {
        Checker::argNat("numBytes", $numBytes);

        $full = '';
        $bytesRemaining = $numBytes;
        while (!feof($inStream) && $bytesRemaining > 0) {
            $part = fread($inStream, $bytesRemaining);
            if ($part === false) throw new StreamReadException("Error reading from \$inStream.");
            $full .= $part;
            $bytesRemaining -= strlen($part);
        }
        return $full;
    }
private static function readFully($inStream, $numBytes)
    {
        Checker::argNat("numBytes", $numBytes);

        $full = '';
        $bytesRemaining = $numBytes;
        while (!feof($inStream) && $bytesRemaining > 0) {
            $part = fread($inStream, $bytesRemaining);
            if ($part === false) throw new StreamReadException("Error reading from \$inStream.");
            $full .= $part;
            $bytesRemaining -= strlen($part);
        }
        return $full;
    }
Sometimes fread() returns less than the request number of bytes (for example, when reading
from network streams).  This function repeatedly calls fread until the requested number of
bytes have been read or we've reached EOF.

@param resource $inStream
@param int $numBytes
@throws StreamReadException
@return string