@@ -441,7 +441,7 @@ public function getJavascriptRenderer($baseUrl = null, $basePath = null)
441
441
/**
442
442
* Modify the response and inject the debugbar (or data in headers)
443
443
*
444
- * @param \Illuminate\Http \Request $request
444
+ * @param \Symfony\Component\HttpFoundation \Request $request
445
445
* @param \Symfony\Component\HttpFoundation\Response $response
446
446
* @return \Symfony\Component\HttpFoundation\Response
447
447
*/
@@ -501,14 +501,14 @@ public function modifyResponse($request, $response)
501
501
}
502
502
}
503
503
504
- if ($ response ->isRedirection () || !( $ request instanceof \ Illuminate \ Http \Request) ) {
504
+ if ($ response ->isRedirection ()) {
505
505
try {
506
506
$ this ->stackData ();
507
507
} catch (\Exception $ e ) {
508
508
$ app ['log ' ]->error ('Debugbar exception: ' . $ e ->getMessage ());
509
509
}
510
510
} elseif (
511
- ( $ request -> isXmlHttpRequest () || $ request-> wantsJson () ) and
511
+ $ this -> isJsonRequest ( $ request ) and
512
512
$ app ['config ' ]->get ('laravel-debugbar::config.capture_ajax ' , true )
513
513
) {
514
514
try {
@@ -519,7 +519,7 @@ public function modifyResponse($request, $response)
519
519
} elseif (
520
520
($ response ->headers ->has ('Content-Type ' ) and
521
521
strpos ($ response ->headers ->get ('Content-Type ' ), 'html ' ) === false )
522
- || ' html ' !== $ request ->format ()
522
+ || $ request ->getRequestFormat () !== ' html '
523
523
) {
524
524
try {
525
525
// Just collect + store data, don't inject it.
@@ -559,6 +559,22 @@ protected function isDebugbarRequest()
559
559
{
560
560
return $ this ->app ['request ' ]->segment (1 ) == '_debugbar ' ;
561
561
}
562
+
563
+ /**
564
+ * @param \Symfony\Component\HttpFoundation\Request $request
565
+ * @return bool
566
+ */
567
+ protected function isJsonRequest ($ request )
568
+ {
569
+ // If XmlHttpRequest, return true
570
+ if ($ request ->isXmlHttpRequest ()) {
571
+ return true ;
572
+ }
573
+
574
+ // Check if the request wants Json
575
+ $ acceptable = $ request ->getAcceptableContentTypes ();
576
+ return (isset ($ acceptable [0 ]) && $ acceptable [0 ] == 'application/json ' );
577
+ }
562
578
563
579
/**
564
580
* Collects the data from the collectors
0 commit comments