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:
@@ -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) {
|
||||
|
@@ -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;
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user