Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding 421 Misdirected Request HTTP Exception #2902

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ The following error classes exist in Werkzeug:

.. autoexception:: ImATeapot

.. autoexception:: MisdirectedRequest

.. autoexception:: UnprocessableEntity

.. autoexception:: Locked
Expand Down
11 changes: 11 additions & 0 deletions src/werkzeug/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
1 change: 1 addition & 0 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down