瀏覽代碼

[HttpFoundation] Fixed charset always being set to UTF-8

Fixes #1281
Aurélien Fredouelle 14 年之前
父節點
當前提交
1e50a553d2
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      src/Symfony/Component/HttpFoundation/Response.php

+ 3 - 3
src/Symfony/Component/HttpFoundation/Response.php

@@ -89,7 +89,6 @@ class Response
         if (!$this->headers->has('Date')) {
         if (!$this->headers->has('Date')) {
             $this->setDate(new \DateTime(null, new \DateTimeZone('UTC')));
             $this->setDate(new \DateTime(null, new \DateTimeZone('UTC')));
         }
         }
-        $this->charset = 'UTF-8';
     }
     }
 
 
     /**
     /**
@@ -745,11 +744,12 @@ class Response
 
 
     protected function fixContentType()
     protected function fixContentType()
     {
     {
+	$charset = $this->charset ?: 'UTF-8';
         if (!$this->headers->has('Content-Type')) {
         if (!$this->headers->has('Content-Type')) {
-            $this->headers->set('Content-Type', 'text/html; charset='.$this->charset);
+            $this->headers->set('Content-Type', 'text/html; charset='.$charset);
         } elseif ('text/' === substr($this->headers->get('Content-Type'), 0, 5) && false === strpos($this->headers->get('Content-Type'), 'charset')) {
         } elseif ('text/' === substr($this->headers->get('Content-Type'), 0, 5) && false === strpos($this->headers->get('Content-Type'), 'charset')) {
             // add the charset
             // add the charset
-            $this->headers->set('Content-Type', $this->headers->get('Content-Type').'; charset='.$this->charset);
+            $this->headers->set('Content-Type', $this->headers->get('Content-Type').'; charset='.$charset);
         }
         }
     }
     }
 }
 }