Index: django/http/__init__.py
===================================================================
--- django/http/__init__.py	(revision 13007)
+++ django/http/__init__.py	(working copy)
@@ -21,6 +21,8 @@
 
 absolute_http_url_re = re.compile(r"^https?://", re.I)
 
+_charset_from_content_type_re = re.compile(r';\s*charset=([^\s;]+)', re.I)
+
 class Http404(Exception):
     pass
 
@@ -303,11 +305,10 @@
 
     def __init__(self, content='', mimetype=None, status=None,
             content_type=None):
-        from django.conf import settings
-        self._charset = settings.DEFAULT_CHARSET
         if mimetype:
             content_type = mimetype     # For backwards compatibility
         if not content_type:
+            from django.conf import settings
             content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE,
                     settings.DEFAULT_CHARSET)
         if not isinstance(content, basestring) and hasattr(content, '__iter__'):
@@ -400,6 +401,20 @@
 
     content = property(_get_content, _set_content)
 
+    def _get_charset(self):
+        def _unquote(value):
+            if value and value[0] == value[-1] == '"':
+                return value[1:-1]
+            return value
+
+        matched = _charset_from_content_type_re.search(self["Content-type"])
+        if not matched:
+            from django.conf import settings
+            return settings.DEFAULT_CHARSET
+        return _unquote(matched.group(1))
+
+    _charset = property(_get_charset)
+
     def __iter__(self):
         self._iterator = iter(self._container)
         return self
Index: tests/regressiontests/http_response_charset/__init__.py
===================================================================
Index: tests/regressiontests/http_response_charset/tests.py
===================================================================
--- tests/regressiontests/http_response_charset/tests.py	(revision 0)
+++ tests/regressiontests/http_response_charset/tests.py	(revision 0)
@@ -0,0 +1,39 @@
+from django.conf import settings
+from django.http import HttpResponse
+from django.test import TestCase
+
+
+class HttpResponseCharsetDetectionTest(TestCase):
+    """Test of the charset detection from the ``Content-type`` header."""
+
+    def setUp(self):
+        self._charset_backup = settings.DEFAULT_CHARSET
+        settings.DEFAULT_CHARSET = "iso-8859-1"
+
+    def tearDown(self):
+        settings.DEFAULT_CHARSET = self._charset_backup
+
+    def testShouldAssumeDefaultCharsetWhenContentTypeIsNotGiven(self):
+        response = HttpResponse('ok')
+        self.assertEqual(response._charset, settings.DEFAULT_CHARSET)
+
+    def testShouldDetectUnquotedCharset(self):
+        content_type = "text/plain; charset=utf-8"
+        response = HttpResponse('ok', content_type=content_type)
+        self.assertEqual(response._charset, 'utf-8')
+
+    def testShouldDetectQuotedCharset(self):
+        content_type = 'text/plain; charset="utf-8"'
+        response = HttpResponse('ok', content_type=content_type)
+        self.assertEqual(response._charset, "utf-8")
+
+    def testShouldAssumeDefaultCharsetWhenTheCharsetIsEmpty(self):
+        content_type = 'text/plain; charset='
+        response = HttpResponse('ok', content_type=content_type)
+        self.assertEqual(response._charset, settings.DEFAULT_CHARSET)
+
+    def testShouldAssumeDefaultCharsetWhenTheCharsetIsNotGiven(self):
+        content_type = 'text/plain'
+        response = HttpResponse('ok', content_type=content_type)
+        self.assertEqual(response._charset, settings.DEFAULT_CHARSET)
+
Index: tests/regressiontests/http_response_charset/models.py
===================================================================
Index: tests/regressiontests/tests_testcase_assertcontains/__init__.py
===================================================================
Index: tests/regressiontests/tests_testcase_assertcontains/tests.py
===================================================================
--- tests/regressiontests/tests_testcase_assertcontains/tests.py	(revision 0)
+++ tests/regressiontests/tests_testcase_assertcontains/tests.py	(revision 0)
@@ -0,0 +1,45 @@
+from django.conf import settings
+from django.http import HttpResponse
+from django.test import TestCase
+
+
+class HttpResponseContentWithNotDefaultCharsetTest(TestCase):
+
+    def setUp(self):
+        self.default_charset = "iso-8859-1"
+        self.content_with_default_charset = "Just latin-1 :)"
+        self.unusual_charset = "utf-8"
+        self.content_with_unusual_charset =  u"Unicode smile \u32e1"
+
+        self._charset_back = settings.DEFAULT_CHARSET
+        settings.DEFAULT_CHARSET = self.default_charset
+
+    def tearDown(self):
+        settings.DEFAULT_CHARSET = self._charset_back
+
+    def testMayOmitContentTypeHeaderWhenContentHasDefaultCharset(self):
+        self.assertEqual(settings.DEFAULT_CHARSET, self.default_charset)
+        response = HttpResponse(self.content_with_default_charset)
+        self.assertContains(response, self.content_with_default_charset)
+
+    def testShouldPassWhenCharsetGivenInTheContentTypeHeader(self):
+        if settings.DEFAULT_CHARSET <> self.unusual_charset:
+            content_type = "text/plain; charset=%s" % self.unusual_charset
+        else:
+            content_type = None
+
+        self.assertEqual(content_type, "text/plain; charset=utf-8")
+        response = HttpResponse(self.content_with_unusual_charset,
+                                content_type=content_type)
+        self.assertContains(response, self.content_with_unusual_charset)
+
+    def testMayBeCrazyIfCharsetIsNotGiven(self):
+        response = HttpResponse(self.content_with_unusual_charset)
+        self.assertRaises(UnicodeEncodeError,
+                self.assertContains, response, self.content_with_unusual_charset)
+
+        response = HttpResponse(self.content_with_unusual_charset,
+                                content_type="text/plain")
+        self.assertRaises(UnicodeEncodeError,
+                self.assertContains, response, self.content_with_unusual_charset)
+
Index: tests/regressiontests/tests_testcase_assertcontains/models.py
===================================================================
