diff options
author | Christian Schneider | 2007-05-08 13:56:22 +0000 |
---|---|---|
committer | Christian Schneider | 2007-05-08 13:56:22 +0000 |
commit | c35d4e4ae45c69b163c5089e84e3bf90f43b59c4 (patch) | |
tree | 07dc30bf0fa87470f3c8463ac4180fa86287f89e | |
parent | b35a4c141ee99dfacf030068c40e9107d649ecd1 (diff) | |
download | itools-c35d4e4ae45c69b163c5089e84e3bf90f43b59c4.tar.gz itools-c35d4e4ae45c69b163c5089e84e3bf90f43b59c4.tar.bz2 itools-c35d4e4ae45c69b163c5089e84e3bf90f43b59c4.zip |
Handle bogus chunked transfer encoding response from Wordpress/Apache2/PHP5
-rw-r--r-- | url.class | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -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; |