summaryrefslogtreecommitdiff
path: root/inc/HTTPClient.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/HTTPClient.php')
-rw-r--r--inc/HTTPClient.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php
index 524dd9a2c..a07d263dd 100644
--- a/inc/HTTPClient.php
+++ b/inc/HTTPClient.php
@@ -456,7 +456,7 @@ class HTTPClient {
$r_body = '';
if(preg_match('/transfer\-(en)?coding:\s*chunked\r\n/i',$r_headers)){
do {
- unset($chunk_size);
+ $chunk_size = '';
do {
if(feof($socket)){
$this->error = 'Premature End of File (socket)';
@@ -471,13 +471,17 @@ class HTTPClient {
}
$byte = fread($socket,1);
$chunk_size .= $byte;
- } while (preg_match('/[a-zA-Z0-9]/',$byte)); // read chunksize including \r
+ } while (preg_match('/^[a-zA-Z0-9]?$/',$byte)); // read chunksize including \r
$byte = fread($socket,1); // readtrailing \n
$chunk_size = hexdec($chunk_size);
if ($chunk_size) {
- $this_chunk = fread($socket,$chunk_size);
- $r_body .= $this_chunk;
+ $read_size = $chunk_size;
+ while ($read_size > 0) {
+ $this_chunk = fread($socket,$read_size);
+ $r_body .= $this_chunk;
+ $read_size -= strlen($this_chunk);
+ }
$byte = fread($socket,2); // read trailing \r\n
}