diff --git a/CHANGES.rst b/CHANGES.rst index 320e4836c..e6f54115f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,7 @@ Unreleased - ``CacheControl.no_transform`` is a boolean when present. ``min_fresh`` is ``None`` when not present. Added the ``must_understand`` attribute. Fixed some typing issues on cache control. :issue:`2881` +- Add 421 ``MisdirectedRequest`` HTTP exception. :issue:`2850` Version 3.0.6 diff --git a/docs/exceptions.rst b/docs/exceptions.rst index 88a309d45..d5b6970b1 100644 --- a/docs/exceptions.rst +++ b/docs/exceptions.rst @@ -44,6 +44,8 @@ The following error classes exist in Werkzeug: .. autoexception:: ImATeapot +.. autoexception:: MisdirectedRequest + .. autoexception:: UnprocessableEntity .. autoexception:: Locked diff --git a/src/werkzeug/exceptions.py b/src/werkzeug/exceptions.py index 6ce7ef955..02af2c15d 100644 --- a/src/werkzeug/exceptions.py +++ b/src/werkzeug/exceptions.py @@ -571,6 +571,17 @@ class ImATeapot(HTTPException): description = "This server is a teapot, not a coffee machine" +class MisdirectedRequest(HTTPException): + """421 Misdirected Request + + Indicates that the request was directed to a server that is not able to + produce a response. + """ + + code = 421 + description = "The server is not able to produce a response." + + class UnprocessableEntity(HTTPException): """*422* `Unprocessable Entity` diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index ad20b3f8b..67d76d2b4 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -37,6 +37,7 @@ def test_proxy_exception(): (exceptions.RequestEntityTooLarge, 413), (exceptions.RequestURITooLarge, 414), (exceptions.UnsupportedMediaType, 415), + (exceptions.MisdirectedRequest, 421), (exceptions.UnprocessableEntity, 422), (exceptions.Locked, 423), (exceptions.InternalServerError, 500),