1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Fixed #1646 -- Added HttpResponseNotAllowed, as suggested by Ian Holsman.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3144 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2006-06-19 02:04:37 +00:00
parent a93b1f7ac3
commit 214d88ce86
2 changed files with 10 additions and 0 deletions

View File

@ -265,6 +265,12 @@ class HttpResponseForbidden(HttpResponse):
HttpResponse.__init__(self, *args, **kwargs)
self.status_code = 403
class HttpResponseNotAllowed(HttpResponse):
def __init__(self, permitted_methods):
HttpResponse.__init__(self)
self['Allow'] = ', '.join(permitted_methods)
self.status_code = 405
class HttpResponseGone(HttpResponse):
def __init__(self, *args, **kwargs):
HttpResponse.__init__(self, *args, **kwargs)

View File

@ -400,6 +400,10 @@ types of HTTP responses. Like ``HttpResponse``, these subclasses live in
``HttpResponseForbidden``
Acts just like ``HttpResponse`` but uses a 403 status code.
``HttpResponseNotAllowed``
Like ``HttpResponse``, but uses a 405 status code. Takes a single,
required argument: a list of permitted methods (e.g. ``['GET', 'POST']``).
``HttpResponseGone``
Acts just like ``HttpResponse`` but uses a 410 status code.