Sfoglia il codice sorgente

[HttpFoundation] made small optimizations

Fabien Potencier 14 anni fa
parent
commit
8dd0c5641a

+ 4 - 1
src/Symfony/Component/HttpFoundation/HeaderBag.php

@@ -31,7 +31,10 @@ class HeaderBag
     {
         $this->cacheControl = array();
         $this->cookies = array();
-        $this->replace($headers);
+        $this->headers = array();
+        foreach ($headers as $key => $values) {
+            $this->set($key, $values);
+        }
     }
 
     /**

+ 1 - 1
src/Symfony/Component/HttpFoundation/ParameterBag.php

@@ -27,7 +27,7 @@ class ParameterBag
      */
     public function __construct(array $parameters = array())
     {
-        $this->replace($parameters);
+        $this->parameters = $parameters;
     }
 
     /**

+ 5 - 1
src/Symfony/Component/HttpFoundation/Request.php

@@ -511,7 +511,11 @@ class Request
 
             $host = trim($elements[count($elements) - 1]);
         } else {
-            $host = $this->headers->get('HOST', $this->server->get('SERVER_NAME', $this->server->get('SERVER_ADDR', '')));
+            if (!$host = $this->headers->get('HOST')) {
+                if (!$host = $this->server->get('SERVER_NAME')) {
+                    $host = $this->server->get('SERVER_ADDR', '');
+                }
+            }
         }
 
         // Remove port number from host