Permalink
Browse files

- option to compress with gzip header data

- limit max sent bytes

Committer: Timo Kiefer <timo@kmcs.de>

On branch master
 Changes to be committed:
   (use "git reset HEAD <file>..." to unstage)

	modified:   packages/core/lib/FirePHPCore/FirePHP.class.php
  • Loading branch information...
1 parent ea7193b commit c032461e6cf97301e36a4c1d9dacc5332a343a7d Timo Kiefer committed Jul 19, 2011
Showing with 26 additions and 2 deletions.
  1. +26 −2 packages/core/lib/FirePHPCore/FirePHP.class.php
@@ -2,6 +2,7 @@
// Authors:
// - cadorn, Christoph Dorn <christoph@christophdorn.com>, Copyright 2007, New BSD License
// - qbbr, Sokolov Innokenty <sokolov.innokenty@gmail.com>, Copyright 2011, New BSD License
+// - timo, Timo Kiefer <timo.kiefer@kmcs.de>, Copyright 2011, New BSD License
/**
* *** BEGIN LICENSE BLOCK *****
*
@@ -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
@@ -247,6 +253,11 @@ class FirePHP {
protected $logToInsightConsole = null;
/**
+ * currently sent bytes
+ */
+ protected $sentBytes = 0;
+
+ /**
* When the object gets serialized only include specific object members.
*
* @return array
@@ -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
@@ -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"));
@@ -1833,4 +1857,4 @@ public function setRendererUrl($URL)
{
trigger_error('The FirePHP::setRendererUrl() method is no longer supported', E_USER_DEPRECATED);
}
-}
+}

0 comments on commit c032461

Please sign in to comment.