Why I get "ERR_RESPONSE_HEADERS_TOO_BIG" on chrome?
Solution 1
Some necroposting for those, who will search an answer :)
I tried to do the similar thing - to unblock parallel ajax requests, one of which called for long operation and other for checking progress.
I also started the session each time to write new value and stopped it right after. And I also got ERR_RESPONSE_HEADERS_TOO_BIG
error in Chrome.
The reason was that PHP sent Set-Cookie
header with each session start in my case. And when long ajax request was finishing, server sent all Set-Cookie
headers to the browser.
To fix this I removed the Set-Cookie
headers by calling
header_remove('Set-Cookie');
before the output.
Solution 2
It's not the case in this questions, but I thought that it would be useful to share that this error could also arise if too much data is being printed/echoed by the server (e.g. for debugging purposes)
Related videos on Youtube
netanalyzer
Updated on September 15, 2022Comments
-
netanalyzer over 1 year
The following code is executed correctly on firefox, but not on Chrome. The later always displays "ERR_RESPONSE_HEADERS_TOO_BIG". This error occurs when I iterate through a folder containing more than 10000 items (files) - it must be long task.
Please can anyone explain me how to avoid this error? The error disappears if I "echo"-ing something just after ob_end_clean();
<?php ini_set('max_execution_time', 600); function FileItemsCount($it, &$count_ref) { foreach ($it as $file) { $count_ref += 1; ob_start(); session_start(); $_SESSION['progress'] = $count_ref; session_write_close(); ob_end_clean() ; $is_folder = $it->hasChildren(); if ($is_folder) { FileItemsCount($it->getChildren(), $count_ref); } } } $dir = "C:/Users/sstefanov/xampp"; $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS); $count = 0; FileItemsCount($it, $count); echo $count; ?>
-
CBroe almost 11 yearsI'd suspect that's because you open and close the session in your loop every time (why are you doing that anyway?) - that might(?) result in session_start generating a new SetCookie header each time, and therefor Chrome get's pissed ...
-
-
chichilatte over 2 yearsThank you! I was getting this with the ChromePhp logger sending back 300KB of debug information.