summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--url.class19
1 files changed, 17 insertions, 2 deletions
diff --git a/url.class b/url.class
index 7f9cfb3..5635dac 100644
--- a/url.class
+++ b/url.class
@@ -287,8 +287,23 @@ function get($p=null, $timeout=5000)
if ($url->result)
{
- while (!feof($fp))
- $url->data .= @fread($fp, 20480);
+ if ($url->headers['Transfer-Encoding'] == "chunked") # Bogus HTTP/1.1 chunked answer from server (e.g. Wordpress/Apach2/PHP5)
+ {
+ while ($len = hexdec(fgets($fp)))
+ {
+ $chunk = "";
+
+ while (!feof($fp) && (strlen($chunk) < $len))
+ $chunk .= @fread($fp, $len - strlen($chunk));
+
+ $url->data .= $chunk;
+ }
+ }
+ else
+ {
+ while (!feof($fp))
+ $url->data .= @fread($fp, 20480);
+ }
if ($url->result < 400)
$result =& $url->data;