summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2007-05-08 13:56:22 +0000
committerChristian Schneider2007-05-08 13:56:22 +0000
commitc35d4e4ae45c69b163c5089e84e3bf90f43b59c4 (patch)
tree07dc30bf0fa87470f3c8463ac4180fa86287f89e
parentb35a4c141ee99dfacf030068c40e9107d649ecd1 (diff)
downloaditools-c35d4e4ae45c69b163c5089e84e3bf90f43b59c4.tar.gz
itools-c35d4e4ae45c69b163c5089e84e3bf90f43b59c4.tar.bz2
itools-c35d4e4ae45c69b163c5089e84e3bf90f43b59c4.zip
Handle bogus chunked transfer encoding response from Wordpress/Apache2/PHP5
-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;