summaryrefslogtreecommitdiff
path: root/django/http
diff options
context:
space:
mode:
authorBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-04-02 15:36:31 +0000
committerBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-04-02 15:36:31 +0000
commita3053273c8a5d450a0cd73ee8deebc277d8c4170 (patch)
tree040ebe76a8c7814e888c6669deec86d6c7ef8940 /django/http
parentb86d69f52920adf8e065bf6952ab6b3814211d4e (diff)
boulder-oracle-sprint: Merged to [4905].
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4906 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/http')
-rw-r--r--django/http/__init__.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py
index 0ae90c4921..ed2c128a16 100644
--- a/django/http/__init__.py
+++ b/django/http/__init__.py
@@ -155,6 +155,9 @@ def parse_cookie(cookie):
class HttpResponse(object):
"A basic HTTP response, with content and dictionary-accessed headers"
+
+ status_code = 200
+
def __init__(self, content='', mimetype=None):
from django.conf import settings
self._charset = settings.DEFAULT_CHARSET
@@ -168,7 +171,6 @@ class HttpResponse(object):
self._is_string = True
self.headers = {'Content-Type': mimetype}
self.cookies = SimpleCookie()
- self.status_code = 200
def __str__(self):
"Full HTTP message, including headers"
@@ -254,47 +256,49 @@ class HttpResponse(object):
return sum([len(chunk) for chunk in self._container])
class HttpResponseRedirect(HttpResponse):
+ status_code = 302
+
def __init__(self, redirect_to):
HttpResponse.__init__(self)
self['Location'] = quote(redirect_to, safe=RESERVED_CHARS)
- self.status_code = 302
class HttpResponsePermanentRedirect(HttpResponse):
+ status_code = 301
+
def __init__(self, redirect_to):
HttpResponse.__init__(self)
self['Location'] = quote(redirect_to, safe=RESERVED_CHARS)
- self.status_code = 301
class HttpResponseNotModified(HttpResponse):
- def __init__(self):
- HttpResponse.__init__(self)
- self.status_code = 304
+ status_code = 304
+
+class HttpResponseBadRequest(HttpResponse):
+ status_code = 400
class HttpResponseNotFound(HttpResponse):
- def __init__(self, *args, **kwargs):
- HttpResponse.__init__(self, *args, **kwargs)
- self.status_code = 404
+ status_code = 404
class HttpResponseForbidden(HttpResponse):
- def __init__(self, *args, **kwargs):
- HttpResponse.__init__(self, *args, **kwargs)
- self.status_code = 403
+ status_code = 403
class HttpResponseNotAllowed(HttpResponse):
+ status_code = 405
+
def __init__(self, permitted_methods):
HttpResponse.__init__(self)
self['Allow'] = ', '.join(permitted_methods)
- self.status_code = 405
class HttpResponseGone(HttpResponse):
+ status_code = 410
+
def __init__(self, *args, **kwargs):
HttpResponse.__init__(self, *args, **kwargs)
- self.status_code = 410
class HttpResponseServerError(HttpResponse):
+ status_code = 500
+
def __init__(self, *args, **kwargs):
HttpResponse.__init__(self, *args, **kwargs)
- self.status_code = 500
def get_host(request):
"Gets the HTTP host from the environment or request headers."