From b35e864619eb848221c9de6bb698c90dfa97c08c Mon Sep 17 00:00:00 2001 From: prathik2401 Date: Sat, 14 Sep 2024 21:59:14 +0530 Subject: [PATCH 1/6] feat (status_codes) update HTTP status code constants wrt RFC 9110 refactor(response): replace falcon.HTTPPayloadTooLarge with falcon.HTTPContentTooLarge Replace the usage of falcon.HTTPPayloadTooLarge with falcon.HTTPContentTooLarge in the codebase. This change aligns with the recent renaming of the class in the Falcon library. The new class name better reflects the purpose of the error, which is to indicate that the content of the request is too large for the server to process. Closes #2322 --- README.rst | 4 ++-- docs/api/errors.rst | 2 +- docs/api/status.rst | 2 +- docs/changes/2.0.0.rst | 4 ++-- examples/things_advanced.py | 2 +- examples/things_advanced_asgi.py | 2 +- falcon/__init__.py | 4 ++-- falcon/errors.py | 6 +++--- falcon/status_codes.py | 4 ++-- tests/test_error.py | 12 ++++++------ tests/test_httperror.py | 4 ++-- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/README.rst b/README.rst index 549e6cddb..03a171e5e 100644 --- a/README.rst +++ b/README.rst @@ -573,7 +573,7 @@ Note that this example assumes that the msg = ('The size of the request is too large. The body must not ' 'exceed ' + str(limit) + ' bytes in length.') - raise falcon.HTTPPayloadTooLarge( + raise falcon.HTTPContentTooLarge( title='Request body is too large', description=msg) return hook @@ -830,7 +830,7 @@ Here's the ASGI version of the app from above. Note that it uses the msg = ('The size of the request is too large. The body must not ' 'exceed ' + str(limit) + ' bytes in length.') - raise falcon.HTTPPayloadTooLarge( + raise falcon.HTTPContentTooLarge( title='Request body is too large', description=msg) return hook diff --git a/docs/api/errors.rst b/docs/api/errors.rst index 462e188a6..d655b2a72 100644 --- a/docs/api/errors.rst +++ b/docs/api/errors.rst @@ -152,7 +152,7 @@ Predefined Errors .. autoclass:: falcon.HTTPPreconditionFailed :members: -.. autoclass:: falcon.HTTPPayloadTooLarge +.. autoclass:: falcon.HTTPContentTooLarge :members: .. autoclass:: falcon.HTTPUriTooLong diff --git a/docs/api/status.rst b/docs/api/status.rst index c48d7c918..f417ea210 100644 --- a/docs/api/status.rst +++ b/docs/api/status.rst @@ -167,7 +167,7 @@ HTTPStatus HTTP_410 = '410 Gone' HTTP_411 = '411 Length Required' HTTP_412 = '412 Precondition Failed' - HTTP_413 = '413 Payload Too Large' + HTTP_413 = '413 Content Too Large' HTTP_414 = '414 URI Too Long' HTTP_415 = '415 Unsupported Media Type' HTTP_416 = '416 Range Not Satisfiable' diff --git a/docs/changes/2.0.0.rst b/docs/changes/2.0.0.rst index 999577962..c74f8e7f4 100644 --- a/docs/changes/2.0.0.rst +++ b/docs/changes/2.0.0.rst @@ -168,7 +168,7 @@ Breaking Changes - :attr:`~.falcon.RequestOptions.auto_parse_qs_csv` now defaults to ``False`` instead of ``True``. - The ``HTTPRequestEntityTooLarge`` class was renamed to - :class:`~falcon.HTTPPayloadTooLarge`. + :class:`~falcon.HTTPContentTooLarge`. - Two of the keyword arguments for :meth:`~falcon.Request.get_param_as_int` were renamed to avoid shadowing built-in Python names:: @@ -364,7 +364,7 @@ Fixed - The :meth:`~falcon.testing.TestClient.simulate_request` method now forces header values to `str` on Python 2 as required by PEP-3333. - The ``HTTPRequestEntityTooLarge`` class was renamed to - :class:`~falcon.HTTPPayloadTooLarge` and the reason phrase was updated + :class:`~falcon.HTTPContentTooLarge` and the reason phrase was updated per RFC 7231. - The :class:`falcon.CaseInsensitiveDict` class now inherits from :class:`collections.abc.MutableMapping` under Python 3, instead of diff --git a/examples/things_advanced.py b/examples/things_advanced.py index e9d8b7802..5ebd1e7ec 100644 --- a/examples/things_advanced.py +++ b/examples/things_advanced.py @@ -141,7 +141,7 @@ def hook(req, resp, resource, params): 'exceed ' + str(limit) + ' bytes in length.' ) - raise falcon.HTTPPayloadTooLarge( + raise falcon.HTTPContentTooLarge( title='Request body is too large', description=msg ) diff --git a/examples/things_advanced_asgi.py b/examples/things_advanced_asgi.py index f6fc6bf5a..c640b32c4 100644 --- a/examples/things_advanced_asgi.py +++ b/examples/things_advanced_asgi.py @@ -143,7 +143,7 @@ async def hook(req, resp, resource, params): 'exceed ' + str(limit) + ' bytes in length.' ) - raise falcon.HTTPPayloadTooLarge( + raise falcon.HTTPContentTooLarge( title='Request body is too large', description=msg ) diff --git a/falcon/__init__.py b/falcon/__init__.py index b9976b643..43676860c 100644 --- a/falcon/__init__.py +++ b/falcon/__init__.py @@ -124,7 +124,7 @@ 'HTTPNotAcceptable', 'HTTPNotFound', 'HTTPNotImplemented', - 'HTTPPayloadTooLarge', + 'HTTPContentTooLarge', 'HTTPPreconditionFailed', 'HTTPPreconditionRequired', 'HTTPRangeNotSatisfiable', @@ -363,7 +363,7 @@ from falcon.errors import HTTPNotAcceptable from falcon.errors import HTTPNotFound from falcon.errors import HTTPNotImplemented -from falcon.errors import HTTPPayloadTooLarge +from falcon.errors import HTTPContentTooLarge from falcon.errors import HTTPPreconditionFailed from falcon.errors import HTTPPreconditionRequired from falcon.errors import HTTPRangeNotSatisfiable diff --git a/falcon/errors.py b/falcon/errors.py index afc1faa8a..4490c395c 100644 --- a/falcon/errors.py +++ b/falcon/errors.py @@ -74,7 +74,7 @@ def on_get(self, req, resp): 'HTTPNotAcceptable', 'HTTPNotFound', 'HTTPNotImplemented', - 'HTTPPayloadTooLarge', + 'HTTPContentTooLarge', 'HTTPPreconditionFailed', 'HTTPPreconditionRequired', 'HTTPRangeNotSatisfiable', @@ -952,8 +952,8 @@ def __init__( ) -class HTTPPayloadTooLarge(HTTPError): - """413 Payload Too Large. +class HTTPContentTooLarge(HTTPError): + """413 Content Too Large. The server is refusing to process a request because the request payload is larger than the server is willing or able to process. diff --git a/falcon/status_codes.py b/falcon/status_codes.py index 80c0b5f82..779c14011 100644 --- a/falcon/status_codes.py +++ b/falcon/status_codes.py @@ -91,8 +91,8 @@ HTTP_LENGTH_REQUIRED: Final[str] = HTTP_411 HTTP_412: Final[str] = '412 Precondition Failed' HTTP_PRECONDITION_FAILED: Final[str] = HTTP_412 -HTTP_413: Final[str] = '413 Payload Too Large' -HTTP_REQUEST_ENTITY_TOO_LARGE: Final[str] = HTTP_413 +HTTP_413: Final[str] = '413 Content Too Large' +HTTP_CONTENT_TOO_LARGE: Final[str] = HTTP_413 HTTP_414: Final[str] = '414 URI Too Long' HTTP_REQUEST_URI_TOO_LONG: Final[str] = HTTP_414 HTTP_415: Final[str] = '415 Unsupported Media Type' diff --git a/tests/test_error.py b/tests/test_error.py index a3665f664..bfd732d7d 100644 --- a/tests/test_error.py +++ b/tests/test_error.py @@ -19,7 +19,7 @@ (falcon.HTTPGone, status.HTTP_410), (falcon.HTTPLengthRequired, status.HTTP_411), (falcon.HTTPPreconditionFailed, status.HTTP_412), - (falcon.HTTPPayloadTooLarge, status.HTTP_413), + (falcon.HTTPContentTooLarge, status.HTTP_413), (falcon.HTTPUriTooLong, status.HTTP_414), (falcon.HTTPUnsupportedMediaType, status.HTTP_415), (falcon.HTTPUnprocessableEntity, status.HTTP_422), @@ -82,7 +82,7 @@ def test_with_default_title_and_desc_args(err, title, args): falcon.HTTPGone, falcon.HTTPLengthRequired, falcon.HTTPPreconditionFailed, - falcon.HTTPPayloadTooLarge, + falcon.HTTPContentTooLarge, falcon.HTTPUriTooLong, falcon.HTTPUnsupportedMediaType, falcon.HTTPUnprocessableEntity, @@ -129,7 +129,7 @@ def test_with_title_desc_and_headers(err): falcon.HTTPGone, falcon.HTTPLengthRequired, falcon.HTTPPreconditionFailed, - falcon.HTTPPayloadTooLarge, + falcon.HTTPContentTooLarge, falcon.HTTPUriTooLong, falcon.HTTPUnsupportedMediaType, falcon.HTTPUnprocessableEntity, @@ -202,7 +202,7 @@ def test_args_kw_only(err, args): [ falcon.HTTPServiceUnavailable, falcon.HTTPTooManyRequests, - falcon.HTTPPayloadTooLarge, + falcon.HTTPContentTooLarge, ], ) def test_with_retry_after(err): @@ -217,7 +217,7 @@ def test_with_retry_after(err): [ falcon.HTTPServiceUnavailable, falcon.HTTPTooManyRequests, - falcon.HTTPPayloadTooLarge, + falcon.HTTPContentTooLarge, ], ) def test_with_retry_after_and_headers(err): @@ -290,7 +290,7 @@ def test_custom_400(err, args, title, desc): 'a, b', True, ), - (falcon.HTTPPayloadTooLarge, 'Retry-After', 'retry_after', 123, '123', False), + (falcon.HTTPContentTooLarge, 'Retry-After', 'retry_after', 123, '123', False), ( falcon.HTTPRangeNotSatisfiable, 'Content-Range', diff --git a/tests/test_httperror.py b/tests/test_httperror.py index a3d68724f..3e5131357 100644 --- a/tests/test_httperror.py +++ b/tests/test_httperror.py @@ -172,7 +172,7 @@ def on_get(self, req, resp): class RequestEntityTooLongResource: def on_get(self, req, resp): - raise falcon.HTTPPayloadTooLarge( + raise falcon.HTTPContentTooLarge( title='Request Rejected', description='Request Body Too Large' ) @@ -182,7 +182,7 @@ def __init__(self, retry_after): self.retry_after = retry_after def on_get(self, req, resp): - raise falcon.HTTPPayloadTooLarge( + raise falcon.HTTPContentTooLarge( title='Request Rejected', description='Request Body Too Large', retry_after=self.retry_after, From 51ac273a601de95383e9fe18d811979cdc691293 Mon Sep 17 00:00:00 2001 From: prathik2401 Date: Mon, 16 Sep 2024 00:07:30 +0530 Subject: [PATCH 2/6] docs(_newsfragments) documented class name change from HTTPPayloadTooLarge to HTTPContentTooLarge --- docs/_newsfragments/2330.newandimproved.rst | 1 + docs/changes/2.0.0.rst | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 docs/_newsfragments/2330.newandimproved.rst diff --git a/docs/_newsfragments/2330.newandimproved.rst b/docs/_newsfragments/2330.newandimproved.rst new file mode 100644 index 000000000..c2562f381 --- /dev/null +++ b/docs/_newsfragments/2330.newandimproved.rst @@ -0,0 +1 @@ +refactor: Replaced :class:`~falcon.HTTPPayloadTooLarge` with :class:`~falcon.HTTPContentTooLarge` to align with the updated class name. diff --git a/docs/changes/2.0.0.rst b/docs/changes/2.0.0.rst index c74f8e7f4..97d96b155 100644 --- a/docs/changes/2.0.0.rst +++ b/docs/changes/2.0.0.rst @@ -168,7 +168,7 @@ Breaking Changes - :attr:`~.falcon.RequestOptions.auto_parse_qs_csv` now defaults to ``False`` instead of ``True``. - The ``HTTPRequestEntityTooLarge`` class was renamed to - :class:`~falcon.HTTPContentTooLarge`. + :class:`~falcon.HTTPPayloadTooLarge`. - Two of the keyword arguments for :meth:`~falcon.Request.get_param_as_int` were renamed to avoid shadowing built-in Python names:: From f20287f34d9c9b76bae3a6ecf05c7a4ff69c8f19 Mon Sep 17 00:00:00 2001 From: Vytautas Liuolia Date: Sun, 22 Sep 2024 23:28:20 +0200 Subject: [PATCH 3/6] fix(status_codes): bring back removed constant for compatibility, fix ruff --- falcon/__init__.py | 4 ++-- falcon/status_codes.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/falcon/__init__.py b/falcon/__init__.py index 093c56e03..4a38d9a95 100644 --- a/falcon/__init__.py +++ b/falcon/__init__.py @@ -355,6 +355,7 @@ from falcon.errors import HTTPBadGateway from falcon.errors import HTTPBadRequest from falcon.errors import HTTPConflict +from falcon.errors import HTTPContentTooLarge from falcon.errors import HTTPFailedDependency from falcon.errors import HTTPForbidden from falcon.errors import HTTPGatewayTimeout @@ -373,7 +374,6 @@ from falcon.errors import HTTPNotAcceptable from falcon.errors import HTTPNotFound from falcon.errors import HTTPNotImplemented -from falcon.errors import HTTPContentTooLarge from falcon.errors import HTTPPreconditionFailed from falcon.errors import HTTPPreconditionRequired from falcon.errors import HTTPRangeNotSatisfiable @@ -530,6 +530,7 @@ from falcon.status_codes import HTTP_BAD_GATEWAY from falcon.status_codes import HTTP_BAD_REQUEST from falcon.status_codes import HTTP_CONFLICT +from falcon.status_codes import HTTP_CONTENT_TOO_LARGE from falcon.status_codes import HTTP_CONTINUE from falcon.status_codes import HTTP_CREATED from falcon.status_codes import HTTP_EARLY_HINTS @@ -568,7 +569,6 @@ from falcon.status_codes import HTTP_PRECONDITION_REQUIRED from falcon.status_codes import HTTP_PROCESSING from falcon.status_codes import HTTP_PROXY_AUTHENTICATION_REQUIRED -from falcon.status_codes import HTTP_REQUEST_ENTITY_TOO_LARGE from falcon.status_codes import HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE from falcon.status_codes import HTTP_REQUEST_TIMEOUT from falcon.status_codes import HTTP_REQUEST_URI_TOO_LONG diff --git a/falcon/status_codes.py b/falcon/status_codes.py index b7e7b76a6..eac36aaff 100644 --- a/falcon/status_codes.py +++ b/falcon/status_codes.py @@ -95,6 +95,7 @@ HTTP_PRECONDITION_FAILED: Final[str] = HTTP_412 HTTP_413: Final[str] = '413 Content Too Large' HTTP_CONTENT_TOO_LARGE: Final[str] = HTTP_413 +HTTP_REQUEST_ENTITY_TOO_LARGE: Final[str] = HTTP_413 HTTP_414: Final[str] = '414 URI Too Long' HTTP_REQUEST_URI_TOO_LONG: Final[str] = HTTP_414 HTTP_415: Final[str] = '415 Unsupported Media Type' @@ -330,6 +331,7 @@ 'HTTP_BAD_GATEWAY', 'HTTP_BAD_REQUEST', 'HTTP_CONFLICT', + 'HTTP_CONTENT_TOO_LARGE', 'HTTP_CONTINUE', 'HTTP_CREATED', 'HTTP_EARLY_HINTS', @@ -369,7 +371,6 @@ 'HTTP_PROCESSING', 'HTTP_PROXY_AUTHENTICATION_REQUIRED', 'HTTP_REQUESTED_RANGE_NOT_SATISFIABLE', - 'HTTP_REQUEST_ENTITY_TOO_LARGE', 'HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE', 'HTTP_REQUEST_TIMEOUT', 'HTTP_REQUEST_URI_TOO_LONG', From f0d4f12b9f9df86143b1826466ac2bb3a8e53586 Mon Sep 17 00:00:00 2001 From: Vytautas Liuolia Date: Sun, 22 Sep 2024 23:48:47 +0200 Subject: [PATCH 4/6] chore: misc touchups --- docs/_newsfragments/2330.newandimproved.rst | 6 +++++- docs/api/status.rst | 2 +- docs/changes/2.0.0.rst | 2 +- falcon/__init__.py | 1 - falcon/status_codes.py | 1 + tests/test_status_codes.py | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/_newsfragments/2330.newandimproved.rst b/docs/_newsfragments/2330.newandimproved.rst index c2562f381..3da4f562d 100644 --- a/docs/_newsfragments/2330.newandimproved.rst +++ b/docs/_newsfragments/2330.newandimproved.rst @@ -1 +1,5 @@ -refactor: Replaced :class:`~falcon.HTTPPayloadTooLarge` with :class:`~falcon.HTTPContentTooLarge` to align with the updated class name. +The class :class:`~falcon.HTTPPayloadTooLarge` was renamed to +:class:`~falcon.HTTPContentTooLarge`, together with the accompanying HTTP +:ref:`status code ` updates, in order to reflect the newest HTTP +semantics as per RFC 9110, Section 15.5.14. +(The old class name remains available as a deprecated compatibility alias.) diff --git a/docs/api/status.rst b/docs/api/status.rst index 39777d9c8..d861c38a7 100644 --- a/docs/api/status.rst +++ b/docs/api/status.rst @@ -139,7 +139,7 @@ HTTPStatus HTTP_GONE = HTTP_410 HTTP_LENGTH_REQUIRED = HTTP_411 HTTP_PRECONDITION_FAILED = HTTP_412 - HTTP_REQUEST_ENTITY_TOO_LARGE = HTTP_413 + HTTP_CONTENT_TOO_LARGE = HTTP_413 HTTP_REQUEST_URI_TOO_LONG = HTTP_414 HTTP_UNSUPPORTED_MEDIA_TYPE = HTTP_415 HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = HTTP_416 diff --git a/docs/changes/2.0.0.rst b/docs/changes/2.0.0.rst index 97d96b155..999577962 100644 --- a/docs/changes/2.0.0.rst +++ b/docs/changes/2.0.0.rst @@ -364,7 +364,7 @@ Fixed - The :meth:`~falcon.testing.TestClient.simulate_request` method now forces header values to `str` on Python 2 as required by PEP-3333. - The ``HTTPRequestEntityTooLarge`` class was renamed to - :class:`~falcon.HTTPContentTooLarge` and the reason phrase was updated + :class:`~falcon.HTTPPayloadTooLarge` and the reason phrase was updated per RFC 7231. - The :class:`falcon.CaseInsensitiveDict` class now inherits from :class:`collections.abc.MutableMapping` under Python 3, instead of diff --git a/falcon/__init__.py b/falcon/__init__.py index 4a38d9a95..3b0c3634e 100644 --- a/falcon/__init__.py +++ b/falcon/__init__.py @@ -304,7 +304,6 @@ 'HTTP_PROCESSING', 'HTTP_PROXY_AUTHENTICATION_REQUIRED', 'HTTP_REQUESTED_RANGE_NOT_SATISFIABLE', - 'HTTP_REQUEST_ENTITY_TOO_LARGE', 'HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE', 'HTTP_REQUEST_TIMEOUT', 'HTTP_REQUEST_URI_TOO_LONG', diff --git a/falcon/status_codes.py b/falcon/status_codes.py index eac36aaff..67011df9c 100644 --- a/falcon/status_codes.py +++ b/falcon/status_codes.py @@ -95,6 +95,7 @@ HTTP_PRECONDITION_FAILED: Final[str] = HTTP_412 HTTP_413: Final[str] = '413 Content Too Large' HTTP_CONTENT_TOO_LARGE: Final[str] = HTTP_413 +HTTP_PAYLOAD_TOO_LARGE: Final[str] = HTTP_413 HTTP_REQUEST_ENTITY_TOO_LARGE: Final[str] = HTTP_413 HTTP_414: Final[str] = '414 URI Too Long' HTTP_REQUEST_URI_TOO_LONG: Final[str] = HTTP_414 diff --git a/tests/test_status_codes.py b/tests/test_status_codes.py index b89736883..b4d23f460 100644 --- a/tests/test_status_codes.py +++ b/tests/test_status_codes.py @@ -17,7 +17,7 @@ def test_statuses_are_in_compliance_with_http_from_python313(self, status): if status_code >= 700: pytest.skip('Codes above 700 are not defined in http package') http_status = http.HTTPStatus(status_code) - if status_code in [413, 418, 422]: + if status_code in [418, 422]: assert http_status.phrase != message else: assert http_status.phrase == message From db2b2672932b73ba1133b2553e230ff914a24386 Mon Sep 17 00:00:00 2001 From: Vytautas Liuolia Date: Thu, 26 Sep 2024 21:44:10 +0200 Subject: [PATCH 5/6] refactor: add a compat alias HTTPPayloadTooLarge ==> HTTPContentTooLarge --- ....newandimproved.rst => 2276.newandimproved.rst} | 0 falcon/__init__.py | 2 ++ falcon/errors.py | 14 +++++++++++++- tests/test_error.py | 6 ++++++ 4 files changed, 21 insertions(+), 1 deletion(-) rename docs/_newsfragments/{2330.newandimproved.rst => 2276.newandimproved.rst} (100%) diff --git a/docs/_newsfragments/2330.newandimproved.rst b/docs/_newsfragments/2276.newandimproved.rst similarity index 100% rename from docs/_newsfragments/2330.newandimproved.rst rename to docs/_newsfragments/2276.newandimproved.rst diff --git a/falcon/__init__.py b/falcon/__init__.py index ffd8ae6fa..e3b3012b5 100644 --- a/falcon/__init__.py +++ b/falcon/__init__.py @@ -124,6 +124,7 @@ 'HTTPNotFound', 'HTTPNotImplemented', 'HTTPContentTooLarge', + 'HTTPPayloadTooLarge', 'HTTPPreconditionFailed', 'HTTPPreconditionRequired', 'HTTPRangeNotSatisfiable', @@ -372,6 +373,7 @@ from falcon.errors import HTTPNotAcceptable from falcon.errors import HTTPNotFound from falcon.errors import HTTPNotImplemented +from falcon.errors import HTTPPayloadTooLarge from falcon.errors import HTTPPreconditionFailed from falcon.errors import HTTPPreconditionRequired from falcon.errors import HTTPRangeNotSatisfiable diff --git a/falcon/errors.py b/falcon/errors.py index fa8228a54..4222b885a 100644 --- a/falcon/errors.py +++ b/falcon/errors.py @@ -37,10 +37,11 @@ def on_get(self, req, resp): from __future__ import annotations from datetime import datetime -from typing import Iterable, Optional, TYPE_CHECKING, Union +from typing import Any, Iterable, Optional, TYPE_CHECKING, Union from falcon.http_error import HTTPError import falcon.status_codes as status +from falcon.util import deprecation from falcon.util.misc import dt_to_http if TYPE_CHECKING: @@ -1025,6 +1026,17 @@ def __init__( ) +# TODO(vytas): Remove in Falcon 5.0. +class HTTPPayloadTooLarge(HTTPContentTooLarge): + """Compatibility alias of :class:`falcon.HTTPContentTooLarge`.""" + + @deprecation.deprecated( + 'HTTPPayloadTooLarge is deprecated; use HTTPContentTooLarge instead.' + ) + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class HTTPUriTooLong(HTTPError): """414 URI Too Long. diff --git a/tests/test_error.py b/tests/test_error.py index d77a0f3bc..60e3e60eb 100644 --- a/tests/test_error.py +++ b/tests/test_error.py @@ -350,3 +350,9 @@ def test_override_header_list( assert header_name in value.headers assert isinstance(value.headers, dict) assert value.headers[header_name] == res + + +def test_http_payload_too_large_deprecation(): + with pytest.warns(match='HTTPContentTooLarge'): + err = errors.HTTPPayloadTooLarge() + assert err.title == '413 Content Too Large' From 769f0f825036bf03c77af581b5f18d1416491dea Mon Sep 17 00:00:00 2001 From: Vytautas Liuolia Date: Thu, 26 Sep 2024 23:29:31 +0200 Subject: [PATCH 6/6] docs: tweaks newsfragment for HTTP status code updates --- docs/_newsfragments/2276.newandimproved.rst | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/_newsfragments/2276.newandimproved.rst b/docs/_newsfragments/2276.newandimproved.rst index 3da4f562d..f8dea9c91 100644 --- a/docs/_newsfragments/2276.newandimproved.rst +++ b/docs/_newsfragments/2276.newandimproved.rst @@ -1,5 +1,11 @@ -The class :class:`~falcon.HTTPPayloadTooLarge` was renamed to -:class:`~falcon.HTTPContentTooLarge`, together with the accompanying HTTP -:ref:`status code ` updates, in order to reflect the newest HTTP -semantics as per RFC 9110, Section 15.5.14. +The class ``falcon.HTTPPayloadTooLarge`` was renamed to +:class:`falcon.HTTPContentTooLarge`, together with the accompanying HTTP +:ref:`status code ` update, in order to reflect the newest HTTP +semantics as per +`RFC 9110, Section 15.5.14 `__. (The old class name remains available as a deprecated compatibility alias.) + +In addition, one new :ref:`status code constant ` was added: +``falcon.HTTP_421`` (also available as ``falcon.HTTP_MISDIRECTED_REQUEST``) +in accordance with +`RFC 9110, Section 15.5.20 `__.