1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-07-28 04:00:43 +02:00

Merge pull request #50 from barryvdh/patch-1

Limit headers to something below 256kB
This commit is contained in:
Maxime Bouroumeau-Fuseau
2014-01-04 13:42:33 -08:00
2 changed files with 13 additions and 2 deletions

View File

@@ -243,12 +243,19 @@ class DebugBar implements ArrayAccess
* @param integer $maxHeaderLength
* @return array
*/
public function getDataAsHeaders($headerName = 'phpdebugbar', $maxHeaderLength = 4096)
public function getDataAsHeaders($headerName = 'phpdebugbar', $maxHeaderLength = 4096, $maxTotalHeaderLength = 250000)
{
$data = rawurlencode(json_encode(array(
'id' => $this->getCurrentRequestId(),
'data' => $this->getData()
)));
if (strlen($data) > $maxTotalHeaderLength){
$data = rawurlencode(json_encode(array(
'error' => 'Maximum header size exceeded'
)));
}
$chunks = array();
while (strlen($data) > $maxHeaderLength) {

View File

@@ -967,7 +967,11 @@ if (typeof(PhpDebugBar) == 'undefined') {
}
var data = this.parseHeaders(raw);
this.debugbar.addDataSet(data.data, data.id, "(ajax)");
if(data.error){
throw new Error('Error loading debugbar data: '+data.error);
}else if(data.data){
this.debugbar.addDataSet(data.data, data.id, "(ajax)");
}
return true;
},