Skip to content

Commit

Permalink
Only send FirePHP headers to browser advertising support for it in th…
Browse files Browse the repository at this point in the history
…eir user agent
  • Loading branch information
Seldaek committed Oct 24, 2011
1 parent f13a538 commit b704c49
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.mdown
@@ -1,3 +1,9 @@
* 1.0.2 (2011-10-24)

Changes:

* Fixed bug in IE with large response headers and FirePHPHandler

* 1.0.1 (2011-08-25)

Changes:
Expand Down
16 changes: 15 additions & 1 deletion src/Monolog/Handler/FirePHPHandler.php
Expand Up @@ -52,6 +52,8 @@ class FirePHPHandler extends AbstractProcessingHandler
*/
protected static $messageIndex = 1;

protected $sendHeaders = true;

/**
* Base header creation function used by init headers & record headers
*
Expand Down Expand Up @@ -116,7 +118,7 @@ protected function getInitHeaders()
*/
protected function sendHeader($header, $content)
{
if (!headers_sent()) {
if (!headers_sent() && $this->sendHeaders) {
header(sprintf('%s: %s', $header, $content));
}
}
Expand All @@ -132,6 +134,8 @@ protected function write(array $record)
{
// WildFire-specific headers must be sent prior to any messages
if (!self::$initialized) {
$this->sendHeaders = $this->headersAccepted();

foreach ($this->getInitHeaders() as $header => $content) {
$this->sendHeader($header, $content);
}
Expand All @@ -142,4 +146,14 @@ protected function write(array $record)
$header = $this->createRecordHeader($record);
$this->sendHeader(key($header), current($header));
}

/**
* Verifies if the headers are accepted by the current user agent
*
* @return Boolean
*/
protected function headersAccepted()
{
return !isset($_SERVER['HTTP_USER_AGENT']) || preg_match('{\bFirePHP/\d+\.\d+\b}', $_SERVER['HTTP_USER_AGENT']);
}
}

0 comments on commit b704c49

Please sign in to comment.