summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2018-06-15 01:00:27 -0500
committerMichael Merickel <michael@merickel.org>2018-06-15 01:00:27 -0500
commitc622cdb279948c61f63e7d2a51d10b967292cf4b (patch)
tree651d3f2beaeda6fa1868d6ca49ce68edfc5e9990
parent2fd7905a9d4427ea6dbeaff35f44855c824e470d (diff)
parente6c7eafdfcbb1dc8365720a28c92e847bf2e172f (diff)
downloadpyramid-c622cdb279948c61f63e7d2a51d10b967292cf4b.tar.gz
pyramid-c622cdb279948c61f63e7d2a51d10b967292cf4b.tar.bz2
pyramid-c622cdb279948c61f63e7d2a51d10b967292cf4b.zip
Merge branch 'pr/3302'
-rw-r--r--CHANGES.rst4
-rw-r--r--CONTRIBUTORS.txt2
-rw-r--r--docs/api/httpexceptions.rst2
-rw-r--r--pyramid/httpexceptions.py25
4 files changed, 28 insertions, 5 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index aeb7c3f9a..e09c3723c 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -37,6 +37,10 @@ Features
``pyramid.session.UnencryptedCookieSessionFactoryConfig``.
See https://github.com/Pylons/pyramid/pull/3300
+- Added new ``pyramid.httpexceptions.HTTPPermanentRedirect``
+ exception/response object for a HTTP 308 redirect.
+ See https://github.com/Pylons/pyramid/pull/3302
+
Bug Fixes
---------
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 69ed023b0..a28240adf 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -322,3 +322,5 @@ Contributors
- Junhak Lee, 2018/05/14
- Alex Gaynor, 2018/05/24
+
+- Jason Williams, 2018/06/11
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
############################################################