Permalink
Browse files

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
  • Loading branch information...
1 parent 548a64e commit 7d15c9d93aa40b57052c2f3f515914d592d88201 @markstory markstory committed Apr 8, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 cake/libs/cake_socket.php
@@ -212,8 +212,14 @@ function write($data) {
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;
}
/**

0 comments on commit 7d15c9d

Please sign in to comment.