Merge branch '1.0'
commit
31dcc0bdea
|
@ -76,7 +76,7 @@ class GzipDownloader extends ArchiveDownloader
|
|||
$archiveFile = gzopen($file, 'rb');
|
||||
$targetFile = fopen($targetFilepath, 'wb');
|
||||
while ($string = gzread($archiveFile, 4096)) {
|
||||
fwrite($targetFile, $string, strlen($string));
|
||||
fwrite($targetFile, $string, Platform::strlen($string));
|
||||
}
|
||||
gzclose($archiveFile);
|
||||
fclose($targetFile);
|
||||
|
|
|
@ -26,4 +26,22 @@ class Platform
|
|||
{
|
||||
return defined('PHP_WINDOWS_VERSION_BUILD');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $str
|
||||
* @return int return a guaranteed binary length of the string, regardless of silly mbstring configs
|
||||
*/
|
||||
public static function strlen($str)
|
||||
{
|
||||
static $useMbString = null;
|
||||
if (null === $useMbString) {
|
||||
$useMbString = function_exists('mb_strlen') && ini_get('mbstring.func_overload');
|
||||
}
|
||||
|
||||
if ($useMbString) {
|
||||
return mb_strlen($str, '8bit');
|
||||
}
|
||||
|
||||
return strlen($str);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,7 +279,7 @@ class RemoteFilesystem
|
|||
try {
|
||||
$result = file_get_contents($fileUrl, false, $ctx);
|
||||
|
||||
if ($this->bytesMax && strlen($result) < $this->bytesMax) {
|
||||
if ($this->bytesMax && Platform::strlen($result) < $this->bytesMax) {
|
||||
// alas, this is not possible via the stream callback because STREAM_NOTIFY_COMPLETED is documented, but not implemented anywhere in PHP
|
||||
throw new TransportException('Content-Length mismatch');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue