Browse Source

Added minor optimizations to request handler

Jose Lorenzo Rodriguez 9 years ago
parent
commit
709c1ef707
1 changed files with 8 additions and 3 deletions
  1. 8 3
      src/Controller/Component/RequestHandlerComponent.php

+ 8 - 3
src/Controller/Component/RequestHandlerComponent.php

@@ -159,7 +159,7 @@ class RequestHandlerComponent extends Component
     protected function _setExtension($request, $response)
     {
         $accept = $request->parseAccept();
-        if (empty($accept)) {
+        if (empty($accept) || current($accept)[0] === 'text/html') {
             return;
         }
 
@@ -202,11 +202,16 @@ class RequestHandlerComponent extends Component
         if (empty($this->ext) || in_array($this->ext, ['html', 'htm'])) {
             $this->_setExtension($request, $this->response);
         }
-        if (empty($this->ext) && $request->is('ajax')) {
+
+        $request->params['isAjax'] = $request->is('ajax');
+
+        if (empty($this->ext) && $request->params['isAjax']) {
             $this->ext = 'ajax';
         }
 
-        $request->params['isAjax'] = $this->request->is('ajax');
+        if ($request->is(['get', 'head', 'options'])) {
+            return;
+        }
 
         foreach ($this->config('inputTypeMap') as $type => $handler) {
             if (!is_callable($handler[0])) {