Skip to content

Commit

Permalink
Only add server timing on ajax, when enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh authored Mar 31, 2017
1 parent 6b2f13f commit 41df91e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/LaravelDebugbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,11 @@ public function modifyResponse(Request $request, Response $response)
) {
try {
$this->sendDataInHeaders(true);

if ($app['config']->get('debugbar.add_ajax_timing', false)) {
$this->addServerTimingHeaders($response);
}

} catch (\Exception $e) {
$app['log']->error('Debugbar exception: ' . $e->getMessage());
}
Expand All @@ -670,7 +675,7 @@ public function modifyResponse(Request $request, Response $response)
}
}

$this->addServerTimingHeaders($response);


return $response;
}
Expand Down Expand Up @@ -979,6 +984,7 @@ protected function addServerTimingHeaders(Response $response)
if ($this->hasCollector('time')) {
$collector = $this->getCollector('time');

$headers = [];
foreach ($collector->collect()['measures'] as $k => $m) {
$headers[] = sprintf('%d=%F; "%s"', $k, $m['duration'], str_replace('"', "'", $m['label']));
}
Expand Down

0 comments on commit 41df91e

Please sign in to comment.