summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Williams <jaswilli@gmail.com>2018-06-11 15:55:17 -0500
committerJason Williams <jaswilli@gmail.com>2018-06-11 16:39:19 -0500
commit56cbb5242ced12a73d9e710fb7e227996b841ef1 (patch)
tree193e426771a3d515da6c51d453ebc2ac3bb427d3
parent2fd7905a9d4427ea6dbeaff35f44855c824e470d (diff)
downloadpyramid-56cbb5242ced12a73d9e710fb7e227996b841ef1.tar.gz
pyramid-56cbb5242ced12a73d9e710fb7e227996b841ef1.tar.bz2
pyramid-56cbb5242ced12a73d9e710fb7e227996b841ef1.zip
Add httpexception for status code 308
-rw-r--r--docs/api/httpexceptions.rst2
-rw-r--r--pyramid/httpexceptions.py25
2 files changed, 22 insertions, 5 deletions
diff --git a/docs/api/httpexceptions.rst b/docs/api/httpexceptions.rst
index d4cf97f1d..e25a07cd5 100644
--- a/docs/api/httpexceptions.rst
+++ b/docs/api/httpexceptions.rst
@@ -51,6 +51,8 @@
.. autoexception:: HTTPTemporaryRedirect
+ .. autoexception:: HTTPPermanentRedirect
+
.. autoexception:: HTTPBadRequest
.. autoexception:: HTTPUnauthorized
diff --git a/pyramid/httpexceptions.py b/pyramid/httpexceptions.py
index 718d51b50..bef8420b1 100644
--- a/pyramid/httpexceptions.py
+++ b/pyramid/httpexceptions.py
@@ -7,7 +7,7 @@ single HTTP status code. Each class is a subclass of the
:class:`~HTTPException`. Each exception class is also a :term:`response`
object.
-Each exception class has a status code according to :rfc:`2068`:
+Each exception class has a status code according to :rfc:`2068` or :rfc:`7538`:
codes with 100-300 are not really errors; 400s are client errors,
and 500s are server errors.
@@ -29,6 +29,7 @@ Exception
* 304 - HTTPNotModified
* 305 - HTTPUseProxy
* 307 - HTTPTemporaryRedirect
+ * 308 - HTTPPermanentRedirect
HTTPError
HTTPClientError
* 400 - HTTPBadRequest
@@ -121,10 +122,11 @@ passed to the exception's constructor.
The subclasses of :class:`~_HTTPMove`
(:class:`~HTTPMultipleChoices`, :class:`~HTTPMovedPermanently`,
-:class:`~HTTPFound`, :class:`~HTTPSeeOther`, :class:`~HTTPUseProxy` and
-:class:`~HTTPTemporaryRedirect`) are redirections that require a ``Location``
-field. Reflecting this, these subclasses have one additional keyword argument:
-``location``, which indicates the location to which to redirect.
+:class:`~HTTPFound`, :class:`~HTTPSeeOther`, :class:`~HTTPUseProxy`,
+:class:`~HTTPTemporaryRedirect`, and :class: `~HTTPPermanentRedirect) are
+redirections that require a ``Location`` field. Reflecting this, these
+subclasses have one additional keyword argument: ``location``,
+which indicates the location to which to redirect.
"""
import json
@@ -595,6 +597,19 @@ class HTTPTemporaryRedirect(_HTTPMove):
code = 307
title = 'Temporary Redirect'
+class HTTPPermanentRedirect(_HTTPMove):
+ """
+ subclass of :class:`~_HTTPMove`
+
+ This indicates that the requested resource resides permanently
+ under a different URI and that the request method must not be
+ changed.
+
+ code: 308, title: Permanent Redirect
+ """
+ code = 308
+ title = 'Permanent Redirect'
+
############################################################
## 4xx client error
############################################################