Przeglądaj źródła

[HttpFoundation] added missing CONTENT_TYPE and CONTENT_LENGTH to the Request headers (these two headers are not prefixes with HTTP_ -- as per the CGI/1.1 spec, closes #1234)

Fabien Potencier 14 lat temu
rodzic
commit
f16e206cd7

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

@@ -308,7 +308,12 @@ class Request
         // FIXME: populate $_FILES
 
         foreach ($this->headers->all() as $key => $value) {
-            $_SERVER['HTTP_'.strtoupper(str_replace('-', '_', $key))] = implode(', ', $value);
+            $key = strtoupper(str_replace('-', '_', $key));
+            if (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) {
+                $_SERVER[$key] = implode(', ', $value);
+            } else {
+                $_SERVER['HTTP_'.$key] = implode(', ', $value);
+            }
         }
 
         // FIXME: should read variables_order and request_order

+ 7 - 0
src/Symfony/Component/HttpFoundation/ServerBag.php

@@ -28,6 +28,13 @@ class ServerBag extends ParameterBag
             }
         }
 
+        // CONTENT_TYPE and CONTENT_LENGTH are not prefixed with HTTP_
+        foreach (array('CONTENT_TYPE', 'CONTENT_LENGTH') as $key) {
+            if (isset($this->parameters[$key])) {
+                $headers[$key] = $this->parameters[$key];
+            }
+        }
+
         return $headers;
     }
 }