diff options
author | Tom N Harris <tnharris@whoopdedo.org> | 2012-06-16 03:23:17 -0400 |
---|---|---|
committer | Tom N Harris <tnharris@whoopdedo.org> | 2012-06-18 21:47:10 -0400 |
commit | fc6c2b2f78f7278af30dd2dd0758e90ae771322e (patch) | |
tree | 94815801dbec3b3860a2828d5f26033baefd7037 /inc/HTTPClient.php | |
parent | a09831ea8abf0abcf3e7f72f0974dc5e0fc301c8 (diff) | |
download | rpg-fc6c2b2f78f7278af30dd2dd0758e90ae771322e.tar.gz rpg-fc6c2b2f78f7278af30dd2dd0758e90ae771322e.tar.bz2 |
Correct handling of chunked transfer encoding. (FS#2535)
Diffstat (limited to 'inc/HTTPClient.php')
-rw-r--r-- | inc/HTTPClient.php | 12 |
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 } |