diff --git a/django/http/__init__.py b/django/http/__init__.py
index 7782ebe..c6f1046 100644
a
|
b
|
class HttpResponse(object):
|
728 | 728 | class HttpResponseRedirectBase(HttpResponse): |
729 | 729 | allowed_schemes = ['http', 'https', 'ftp'] |
730 | 730 | |
731 | | def __init__(self, redirect_to): |
| 731 | def __init__(self, redirect_to, *args, **kwargs): |
732 | 732 | parsed = urlparse(redirect_to) |
733 | 733 | if parsed.scheme and parsed.scheme not in self.allowed_schemes: |
734 | 734 | raise SuspiciousOperation("Unsafe redirect to URL with protocol '%s'" % parsed.scheme) |
735 | | super(HttpResponseRedirectBase, self).__init__() |
| 735 | super(HttpResponseRedirectBase, self).__init__(*args, **kwargs) |
736 | 736 | self['Location'] = iri_to_uri(redirect_to) |
737 | 737 | |
738 | 738 | class HttpResponseRedirect(HttpResponseRedirectBase): |
… |
… |
class HttpResponseForbidden(HttpResponse):
|
766 | 766 | class HttpResponseNotAllowed(HttpResponse): |
767 | 767 | status_code = 405 |
768 | 768 | |
769 | | def __init__(self, permitted_methods): |
770 | | super(HttpResponseNotAllowed, self).__init__() |
| 769 | def __init__(self, permitted_methods, *args, **kwargs): |
| 770 | super(HttpResponseNotAllowed, self).__init__(*args, **kwargs) |
771 | 771 | self['Allow'] = ', '.join(permitted_methods) |
772 | 772 | |
773 | 773 | class HttpResponseGone(HttpResponse): |
diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt
index 8d514dc..21e99de 100644
a
|
b
|
types of HTTP responses. Like ``HttpResponse``, these subclasses live in
|
731 | 731 | |
732 | 732 | .. class:: HttpResponseRedirect |
733 | 733 | |
734 | | The constructor takes a single argument -- the path to redirect to. This |
735 | | can be a fully qualified URL (e.g. ``'http://www.yahoo.com/search/'``) or |
736 | | an absolute path with no domain (e.g. ``'/search/'``). Note that this |
737 | | returns an HTTP status code 302. |
| 734 | The first argument to the constructor is required -- the path to redirect |
| 735 | to. This can be a fully qualified URL |
| 736 | (e.g. ``'http://www.yahoo.com/search/'``) or an absolute path with no |
| 737 | domain (e.g. ``'/search/'``). See :class:`HttpResponse` for other optional |
| 738 | constructor arguments. Note that this returns an HTTP status code 302. |
738 | 739 | |
739 | 740 | .. class:: HttpResponsePermanentRedirect |
740 | 741 | |
… |
… |
types of HTTP responses. Like ``HttpResponse``, these subclasses live in
|
761 | 762 | |
762 | 763 | .. class:: HttpResponseNotAllowed |
763 | 764 | |
764 | | Like :class:`HttpResponse`, but uses a 405 status code. Takes a single, |
765 | | required argument: a list of permitted methods (e.g. ``['GET', 'POST']``). |
| 765 | Like :class:`HttpResponse`, but uses a 405 status code. The first argument |
| 766 | to the constructor is required: a list of permitted methods (e.g. |
| 767 | ``['GET', 'POST']``). |
766 | 768 | |
767 | 769 | .. class:: HttpResponseGone |
768 | 770 | |
diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py
index c84b2cd..21ba198 100644
a
|
b
|
import pickle
|
6 | 6 | |
7 | 7 | from django.core.exceptions import SuspiciousOperation |
8 | 8 | from django.http import (QueryDict, HttpResponse, HttpResponseRedirect, |
9 | | HttpResponsePermanentRedirect, HttpResponseNotModified, |
| 9 | HttpResponsePermanentRedirect, HttpResponseNotAllowed, |
| 10 | HttpResponseNotModified, |
10 | 11 | SimpleCookie, BadHeaderError, |
11 | 12 | parse_cookie) |
| 13 | from django.test import TestCase |
12 | 14 | from django.utils import six |
13 | 15 | from django.utils import unittest |
14 | 16 | |
… |
… |
class HttpResponseTests(unittest.TestCase):
|
330 | 332 | HttpResponsePermanentRedirect, url) |
331 | 333 | |
332 | 334 | |
333 | | class HttpResponseSubclassesTests(unittest.TestCase): |
| 335 | class HttpResponseSubclassesTests(TestCase): |
| 336 | def test_redirect(self): |
| 337 | response = HttpResponseRedirect('/redirected/') |
| 338 | self.assertEqual(response.status_code, 302) |
| 339 | # Test that standard HttpResponse init args can be used |
| 340 | response = HttpResponseRedirect('/redirected/', |
| 341 | content='The resource has temporarily moved', |
| 342 | content_type='text/html') |
| 343 | self.assertContains(response, 'The resource has temporarily moved', status_code=302) |
| 344 | |
334 | 345 | def test_not_modified(self): |
335 | 346 | response = HttpResponseNotModified() |
336 | 347 | self.assertEqual(response.status_code, 304) |
… |
… |
class HttpResponseSubclassesTests(unittest.TestCase):
|
339 | 350 | response.content = "Hello dear" |
340 | 351 | self.assertNotIn('content-type', response) |
341 | 352 | |
| 353 | def test_not_allowed(self): |
| 354 | response = HttpResponseNotAllowed(['GET']) |
| 355 | self.assertEqual(response.status_code, 405) |
| 356 | # Test that standard HttpResponse init args can be used |
| 357 | response = HttpResponseNotAllowed(['GET'], |
| 358 | content='Only the GET method is allowed', |
| 359 | content_type='text/html') |
| 360 | self.assertContains(response, 'Only the GET method is allowed', status_code=405) |
342 | 361 | |
343 | 362 | class CookieTests(unittest.TestCase): |
344 | 363 | def test_encode(self): |