Fixing CakeSocket::write() to better work with fwrite() oddities

where fwrite() won't actually write all the content, instead only part
of the content would be written. All content should be written now.
Fixes #1616
This commit is contained in:
mark_story 2011-04-07 20:07:36 -04:00
parent 548a64e63b
commit 7d15c9d93a

View file

@ -212,8 +212,14 @@ class CakeSocket extends Object {
return false;
}
}
return fwrite($this->connection, $data, strlen($data));
$totalBytes = strlen($data);
for ($written = 0, $rv = 0; $written < $totalBytes; $written += $rv) {
$rv = fwrite($this->connection, substr($data, $written));
if ($rv === false || $rv === 0) {
return $written;
}
}
return $written;
}
/**