@@ -514,33 +514,29 @@ public function modifyResponse($request, $response)
514514 }
515515 }
516516
517- if ($ response ->isRedirection ()) {
517+ if ($ response ->isRedirection () || !( $ request instanceof \ Illuminate \ Http \Request) ) {
518518 try {
519519 $ this ->stackData ();
520520 } catch (\Exception $ e ) {
521521 $ app ['log ' ]->error ('Debugbar exception: ' . $ e ->getMessage ());
522522 }
523523 } elseif (
524- !($ request instanceof \Illuminate \Http \Request)
525- || ($ response ->headers ->has ('Content-Type ' ) && false === strpos (
526- $ response ->headers ->get ('Content-Type ' ),
527- 'html '
528- ))
529- || 'html ' !== $ request ->format ()
524+ ($ request ->isXmlHttpRequest () || $ request ->wantsJson ()) and
525+ $ app ['config ' ]->get ('laravel-debugbar::config.capture_ajax ' , true )
530526 ) {
531527 try {
532- // Just collect + store data, don't inject it.
533- $ this ->collect ();
528+ $ this ->sendDataInHeaders (true );
534529 } catch (\Exception $ e ) {
535530 $ app ['log ' ]->error ('Debugbar exception: ' . $ e ->getMessage ());
536531 }
537- } elseif (( $ request -> isXmlHttpRequest () || $ request -> wantsJson ()) and $ app [ ' config ' ]-> get (
538- ' laravel-debugbar::config.capture_ajax ' ,
539- true
540- )
532+ } elseif (
533+ ( $ response -> headers -> has ( ' Content-Type ' ) and
534+ strpos ( $ response -> headers -> get ( ' Content-Type ' ), ' html ' ) === false )
535+ || ' html ' !== $ request -> format ( )
541536 ) {
542537 try {
543- $ this ->sendDataInHeaders (true );
538+ // Just collect + store data, don't inject it.
539+ $ this ->collect ();
544540 } catch (\Exception $ e ) {
545541 $ app ['log ' ]->error ('Debugbar exception: ' . $ e ->getMessage ());
546542 }
0 commit comments