function read($bytes) {
if ($bytes) {
fseek($this->_fd, $this->_pos);
- $data = fread($this->_fd, $bytes);
+
+ // PHP 5.1.1 does not read more than 8192 bytes in one fread()
+ // the discussions at PHP Bugs suggest it's the intended behaviour
+ while ($bytes > 0) {
+ $chunk = fread($this->_fd, $bytes);
+ $data .= $chunk;
+ $bytes -= strlen($chunk);
+ }
$this->_pos = ftell($this->_fd);
return $data;