2
0
Эх сурвалжийг харах

Default to html when no content-type is set

Jordi Boggiano 10 жил өмнө
parent
commit
d68b63a0d0

+ 8 - 3
src/Monolog/Handler/BrowserConsoleHandler.php

@@ -104,6 +104,10 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
     /**
     /**
      * Checks the format of the response
      * Checks the format of the response
      *
      *
+     * If Content-Type is set to application/javascript or text/javascript -> js
+     * If Content-Type is set to text/html, or is unset -> html
+     * If Content-Type is anything else -> unknown
+     *
      * @return string One of 'js', 'html' or 'unknown'
      * @return string One of 'js', 'html' or 'unknown'
      */
      */
     protected static function getResponseFormat()
     protected static function getResponseFormat()
@@ -115,14 +119,15 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
                 // text/javascript is obsolete in favour of application/javascript, but still used
                 // text/javascript is obsolete in favour of application/javascript, but still used
                 if (stripos($header, 'application/javascript') !== false || stripos($header, 'text/javascript') !== false) {
                 if (stripos($header, 'application/javascript') !== false || stripos($header, 'text/javascript') !== false) {
                     return 'js';
                     return 'js';
-                } elseif (stripos($header, 'text/html') !== false) {
-                    return 'html';
+                }
+                if (stripos($header, 'text/html') === false) {
+                    return 'unknown';
                 }
                 }
                 break;
                 break;
             }
             }
         }
         }
 
 
-        return 'unknown';
+        return 'html';
     }
     }
 
 
     private static function generateScript()
     private static function generateScript()