--- webdavlib.php.orig 2011-08-26 09:24:28.277469368 +0200 +++ webdavlib.php 2011-08-26 09:40:35.212170935 +0200 @@ -1392,7 +1392,11 @@ fread($this->sock, 1); // also drop off the Line Feed $chunk_size=hexdec($chunk_size); // convert to a number in decimal system if ($chunk_size > 0) { - $buffer .= fread($this->sock,$chunk_size); + $chunk = ''; + while ( strlen($chunk) < $chunk_size ) { + $chunk .= fread($this->sock, $chunk_size - strlen($chunk)); + } + $buffer .= $chunk; } fread($this->sock, 2); // ditch the CRLF that trails the chunk } while ($chunk_size); // till we reach the 0 length chunk (end marker) @@ -1411,12 +1415,10 @@ } } else { // data is to big to handle it as one. Get it chunk per chunk... - do { - $mod = $max_chunk_size % ($matches[1] - strlen($buffer)); - $chunk_size = ($mod == $max_chunk_size ? $max_chunk_size : $matches[1] - strlen($buffer)); + while ( strlen($buffer) < $matches[1] ) { + $chunk_size = ($matches[1] - strlen($buffer)) < $max_chunk_size ? ($matches[1] - strlen($buffer)) : $max_chunk_size; $buffer .= fread($this->sock, $chunk_size); - $this->_error_log('mod: ' . $mod . ' chunk: ' . $chunk_size . ' total: ' . strlen($buffer)); - } while ($mod == $max_chunk_size); + } } break;