Michael Merickel
2018-05-16 1c0eb57f5f961dfc5d53051c28a8ac32dc60308f
Merge pull request #3281 from cewing/1.9-branch

Port 520 fix to 1.9 branch
2 files modified
29 ■■■■ changed files
CHANGES.txt 10 ●●●●● patch | view | raw | blame | history
pyramid/httpexceptions.py 19 ●●●●● patch | view | raw | blame | history
CHANGES.txt
@@ -1,3 +1,13 @@
.. _changes_1.9.3:
1.9.3 (Unreleased)
==================
- Set appropriate ``code`` and ``title`` attributes on the ``HTTPClientError`` and
  ``HTTPServerError`` exception classes. This prevents inadvertently returning a 520
  error code.
  See https://github.com/Pylons/pyramid/pull/3280
.. _changes_1.9.2:
1.9.2 (2018-04-23)
pyramid/httpexceptions.py
@@ -606,7 +606,8 @@
    a bug.  A server-side traceback is not warranted.  Unless specialized,
    this is a '400 Bad Request'
    """
    pass
    code = 400
    title = 'Bad Request'
class HTTPBadRequest(HTTPClientError):
    """
@@ -617,8 +618,6 @@
    code: 400, title: Bad Request
    """
    code = 400
    title = 'Bad Request'
    explanation = ('The server could not comply with the request since '
                   'it is either malformed or otherwise incorrect.')
@@ -1032,11 +1031,18 @@
    This is an error condition in which the server is presumed to be
    in-error.  Unless specialized, this is a '500 Internal Server Error'.
    """
    pass
class HTTPInternalServerError(HTTPServerError):
    code = 500
    title = 'Internal Server Error'
class HTTPInternalServerError(HTTPServerError):
    """
    subclass of :class:`~HTTPServerError`
    This indicates that the server encountered an unexpected condition
    which prevented it from fulfilling the request.
    code: 500, title: Internal Server Error
    """
    explanation = (
        'The server has either erred or is incapable of performing '
        'the requested operation.')
@@ -1150,6 +1156,7 @@
    if (
            isinstance(value, class_types) and
            issubclass(value, HTTPException) and
            value not in {HTTPClientError, HTTPServerError} and
            not name.startswith('_')
    ):
        code = getattr(value, 'code', None)