From 56cbb5242ced12a73d9e710fb7e227996b841ef1 Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Mon, 11 Jun 2018 15:55:17 -0500 Subject: Add httpexception for status code 308 --- docs/api/httpexceptions.rst | 2 ++ pyramid/httpexceptions.py | 25 ++++++++++++++++++++----- 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 ############################################################ -- cgit v1.2.3 From ce9d50b0ce5b4e1197544dced96dfa0f7a0402b0 Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Mon, 11 Jun 2018 15:55:23 -0500 Subject: Sign contributors file --- CONTRIBUTORS.txt | 2 ++ 1 file changed, 2 insertions(+) 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 -- cgit v1.2.3 From e6c7eafdfcbb1dc8365720a28c92e847bf2e172f Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Fri, 15 Jun 2018 00:59:47 -0500 Subject: add changelog for #3302 --- CHANGES.rst | 4 ++++ 1 file changed, 4 insertions(+) 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 --------- -- cgit v1.2.3