Remove chunked transfer encoding header BEFORE saving to cache

This commit is contained in:
Jon goldberg 2017-04-26 16:51:59 -04:00
parent cd4c59a691
commit fed7a8ee7a
1 changed files with 8 additions and 4 deletions

View File

@ -6,7 +6,6 @@
| Author: B. Endres (endres -at- systopia.de) | | Author: B. Endres (endres -at- systopia.de) |
| http://www.systopia.de/ | | http://www.systopia.de/ |
+---------------------------------------------------------*/ +---------------------------------------------------------*/
require_once "config.php"; require_once "config.php";
require_once "proxy.php"; require_once "proxy.php";
@ -105,15 +104,20 @@ $body = $content[1];
// extract headers // extract headers
$header_lines = explode(chr(10), $header); $header_lines = explode(chr(10), $header);
// Remove chunked encoding header
foreach ($header_lines as $k => $header_line) {
if(strpos($header_line,'Transfer-Encoding: chunked') !== FALSE) {
unset($header_lines[$k]);
}
}
// store the information in the cache // store the information in the cache
$file_cache->save(json_encode($header_lines), $header_key); $file_cache->save(json_encode($header_lines), $header_key);
$file_cache->save($body, $data_key); $file_cache->save($body, $data_key);
// and reply // and reply
foreach ($header_lines as $header_line) { foreach ($header_lines as $header_line) {
if($header_line !== 'Transfer-Encoding: chunked ') {
header($header_line); header($header_line);
}
} }
print $body; print $body;