Index: django/http/__init__.py
===================================================================
--- django/http/__init__.py	(revision 6286)
+++ django/http/__init__.py	(working copy)
@@ -240,12 +240,14 @@
         if not content_type:
             content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE,
                     settings.DEFAULT_CHARSET)
-        if not isinstance(content, basestring) and hasattr(content, '__iter__'):
+        self._is_file = False
+        if isinstance(content, file):
             self._container = content
-            self._is_string = False
+            self._is_file = True
+        elif not isinstance(content, basestring) and hasattr(content, '__iter__'):
+            self._container = list(content)
         else:
             self._container = [content]
-            self._is_string = True
         self._headers = {'content-type': content_type}
         self.cookies = SimpleCookie()
         if status:
@@ -299,14 +301,21 @@
 
     def _get_content(self):
         content = smart_str(''.join(self._container), self._charset)
+        self.content = content
         return content
 
     def _set_content(self, value):
         self._container = [value]
-        self._is_string = True
+        self._is_file = False
 
     content = property(_get_content, _set_content)
 
+    def get_content_length(self):
+        if isinstance(self._container, file):
+            if os.path.exists(self._container.name):
+                return os.path.getsize(self._container.name)
+        return len(self.content)
+
     def __iter__(self):
         self._iterator = iter(self._container)
         return self
@@ -324,7 +333,7 @@
     # The remaining methods partially implement the file-like object interface.
     # See http://docs.python.org/lib/bltin-file-objects.html
     def write(self, content):
-        if not self._is_string:
+        if self._is_file:
             raise Exception, "This %s instance is not writable" % self.__class__
         self._container.append(content)
 
@@ -332,7 +341,7 @@
         pass
 
     def tell(self):
-        if not self._is_string:
+        if self._is_file:
             raise Exception, "This %s instance cannot tell its position" % self.__class__
         return sum([len(chunk) for chunk in self._container])
 
Index: django/middleware/http.py
===================================================================
--- django/middleware/http.py	(revision 6286)
+++ django/middleware/http.py	(working copy)
@@ -13,7 +13,9 @@
     def process_response(self, request, response):
         response['Date'] = formatdate()[:26] + "GMT"
         if not response.has_header('Content-Length'):
-            response['Content-Length'] = str(len(response.content))
+            content_length = response.get_content_length()
+            if content_length is not None:
+                response['Content-Length'] = str(content_length)
 
         if response.has_header('ETag'):
             if_none_match = request.META.get('HTTP_IF_NONE_MATCH', None)
Index: tests/regressiontests/httpwrappers/tests.py
===================================================================
--- tests/regressiontests/httpwrappers/tests.py	(revision 6286)
+++ tests/regressiontests/httpwrappers/tests.py	(working copy)
@@ -391,9 +391,38 @@
 >>> q.getlist('foo')
 [u'bar', u'\ufffd']
 
+
+>>> r = HttpResponse()
+>>> r.get_content_length()
+0
+
+>>> r = HttpResponse('foo')
+>>> r.get_content_length()
+3
+
+>>> r = HttpResponse('foo')
+>>> r.write('bar')
+>>> r.get_content_length()
+6
+
+>>> r = HttpResponse(['foo', 'bar', 'foobar'])
+>>> r.get_content_length()
+12
+
+>>> r = HttpResponse(file(__file__))
+>>> assert r.get_content_length() > 0
+
+>>> def ten_foos():
+...     for i in range(10): yield 'foo'
+>>> r = HttpResponse(ten_foos())
+>>> r.get_content_length()
+30
+>>> print r.content
+foofoofoofoofoofoofoofoofoofoo
+
 """
 
-from django.http import QueryDict
+from django.http import QueryDict, HttpResponse
 
 if __name__ == "__main__":
     import doctest
Index: docs/request_response.txt
===================================================================
--- docs/request_response.txt	(revision 6286)
+++ docs/request_response.txt	(working copy)
@@ -431,6 +431,9 @@
 ``write(content)``, ``flush()`` and ``tell()``
     These methods make an ``HttpResponse`` instance a file-like object.
 
+``get_content_length()``
+    Returns the current length of ``content``.
+
 .. _HTTP Status code: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10
 
 HttpResponse subclasses
