diff options
| author | Ryan Allen <ryan@ryangallen.com> | 2016-08-27 20:21:37 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-08-30 21:59:43 -0400 |
| commit | 190d2ff4a7a392adfe0b12552bd71871791d87aa (patch) | |
| tree | 1af46128b86be17a6c89edfe016ba19bd41b58b2 /django | |
| parent | 96ee486ea415a532dbded3209114b98736031118 (diff) | |
Fixed #27153 -- Added validation for HttpResponse status.
Diffstat (limited to 'django')
| -rw-r--r-- | django/http/response.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/http/response.py b/django/http/response.py index c63b446b21..89c1c0a5fd 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -50,7 +50,13 @@ class HttpResponseBase(six.Iterator): self.cookies = SimpleCookie() self.closed = False if status is not None: - self.status_code = status + try: + self.status_code = int(status) + except (ValueError, TypeError): + raise TypeError('HTTP status code must be an integer.') + + if not 100 <= self.status_code <= 599: + raise ValueError('HTTP status code must be an integer from 100 to 599.') self._reason_phrase = reason self._charset = charset if content_type is None: |
