Changeset 5844
- Timestamp:
- 08/11/07 04:37:42 (1 year ago)
- Files:
-
- django/trunk/django/http/__init__.py (modified) (2 diffs)
- django/trunk/docs/request_response.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/http/__init__.py
r5644 r5844 213 213 status_code = 200 214 214 215 def __init__(self, content='', mimetype=None, status=None): 215 def __init__(self, content='', mimetype=None, status=None, 216 content_type=None): 216 217 from django.conf import settings 217 218 self._charset = settings.DEFAULT_CHARSET 218 if not mimetype: 219 mimetype = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE, settings.DEFAULT_CHARSET) 219 if mimetype: 220 content_type = mimetype # For backwards compatibility 221 if not content_type: 222 content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE, 223 settings.DEFAULT_CHARSET) 220 224 if not isinstance(content, basestring) and hasattr(content, '__iter__'): 221 225 self._container = content … … 224 228 self._container = [content] 225 229 self._is_string = True 226 self.headers = {'Content-Type': mimetype}230 self.headers = {'Content-Type': content_type} 227 231 self.cookies = SimpleCookie() 228 232 if status: django/trunk/docs/request_response.txt
r5817 r5844 343 343 ------- 344 344 345 ``__init__(content='', mimetype= DEFAULT_CONTENT_TYPE)``345 ``__init__(content='', mimetype=None, status=200, content_type=DEFAULT_CONTENT_TYPE)`` 346 346 Instantiates an ``HttpResponse`` object with the given page content (a 347 347 string) and MIME type. The ``DEFAULT_CONTENT_TYPE`` is ``'text/html'``. … … 350 350 return strings, and those strings will be joined together to form the 351 351 content of the response. 352 353 ``status`` is the `HTTP Status code`_ for the response. 354 355 **(New in Django development version)** ``content_type`` is an alias for 356 ``mimetype``. Historically, the parameter was only called ``mimetype``, 357 but since this is actually the value included in the HTTP ``Content-Type`` 358 header, it can also include the character set encoding, which makes it 359 more than just a MIME type specification. If ``mimetype`` is specifiedi 360 (not None), that value is used. Otherwise, ``content_type`` is used. If 361 neither is given, the ``DEFAULT_CONTENT_TYPE`` setting is used. 352 362 353 363 ``__setitem__(header, value)`` … … 397 407 These methods make an ``HttpResponse`` instance a file-like object. 398 408 409 .. _HTTP Status code: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10 410 399 411 HttpResponse subclasses 400 412 -----------------------
