Skip to content
Permalink
Browse files

Optimizing mapType

When using RequestHandler component the code tries to guess the extension by checking the Accept header. The current code maps all the types sent as acceptable by the requester (usually browser) and just use the first. This is just a quicker solution where moving the order of the items on the array makes the code to reduce around 400 loops with in_array check inside for requests coming from the most common browsers (Chrome, Safari, Firefox, IE).
  • Loading branch information...
jrbasso committed May 31, 2016
1 parent 445e0cc commit 4a2b8d841e7ba7166c4b9ea99b926dd4e1517f7f
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/Network/Response.php
@@ -90,6 +90,8 @@ class Response
'html' => ['text/html', '*/*'],
'json' => 'application/json',
'xml' => ['application/xml', 'text/xml'],
'xhtml' => ['application/xhtml+xml', 'application/xhtml', 'text/xhtml'],
'webp' => 'image/webp',
'rss' => 'application/rss+xml',
'ai' => 'application/postscript',
'bcpio' => 'application/x-bcpio',
@@ -283,7 +285,6 @@ class Response
'javascript' => 'application/javascript',
'form' => 'application/x-www-form-urlencoded',
'file' => 'multipart/form-data',
'xhtml' => ['application/xhtml+xml', 'application/xhtml', 'text/xhtml'],
'xhtml-mobile' => 'application/vnd.wap.xhtml+xml',
'atom' => 'application/atom+xml',
'amf' => 'application/x-amf',
@@ -292,7 +293,6 @@ class Response
'wmlscript' => 'text/vnd.wap.wmlscript',
'wbmp' => 'image/vnd.wap.wbmp',
'woff' => 'application/x-font-woff',
'webp' => 'image/webp',
'appcache' => 'text/cache-manifest',
'manifest' => 'text/cache-manifest',
'htc' => 'text/x-component',

0 comments on commit 4a2b8d8

Please sign in to comment.
You can’t perform that action at this time.