Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions packages/core/lib/FirePHPCore/FirePHP.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Authors:
// - cadorn, Christoph Dorn <[email protected]>, Copyright 2007, New BSD License
// - qbbr, Sokolov Innokenty <[email protected]>, Copyright 2011, New BSD License
// - timo, Timo Kiefer <[email protected]>, Copyright 2011, New BSD License
/**
* *** BEGIN LICENSE BLOCK *****
*
Expand Down Expand Up @@ -213,7 +214,12 @@ class FirePHP {
'maxObjectDepth' => 5,
'maxArrayDepth' => 5,
'useNativeJsonEncode' => true,
'includeLineNumbers' => true);
'includeLineNumbers' => true,
//use gzip to reduce large header size,
//FirePHP Extension with gzip implementation is required!!
'useGzipEncode' => true,
//~32k max sent size of headers, leave empty for unlimited
'maxBytes' => 32000);

/**
* Filters used to exclude object members when encoding
Expand Down Expand Up @@ -246,6 +252,11 @@ class FirePHP {
*/
protected $logToInsightConsole = null;

/**
* currently sent bytes
*/
protected $sentBytes = 0;

/**
* When the object gets serialized only include specific object members.
*
Expand Down Expand Up @@ -719,6 +730,9 @@ public function detectClientExtension()
// Check if FirePHP is installed on client via User-Agent header
if (@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si', $this->getUserAgent(), $m) &&
version_compare($m[1][0], '0.0.6', '>=')) {
if(!version_compare($m[1][0], '0.6', '>=')) {
$this->setOption('useGzipEncode', false);
}
return true;
} else
// Check if FirePHP is installed on client via X-FirePHP-Version header
Expand Down Expand Up @@ -1063,6 +1077,16 @@ public function fb($object)
}
$msg = '[' . $this->jsonEncode($msgMeta) . ',' . $this->jsonEncode($object, $skipFinalObjectEncode) . ']';
}


if($this->options['useGzipEncode'] && function_exists('gzencode')) {
$this->setHeader('X-Wf-Option-gzip', 'true');
$msg = base64_encode(gzencode($msg));
}

if(!empty($this->options['maxBytes']) && $this->options['maxBytes'] < ($this->sentBytes + strlen($msg))) {
return;
}

$parts = explode("\n", chunk_split($msg, 5000, "\n"));

Expand Down Expand Up @@ -1833,4 +1857,4 @@ public function setRendererUrl($URL)
{
trigger_error('The FirePHP::setRendererUrl() method is no longer supported', E_USER_DEPRECATED);
}
}
}