From 05011930bbfaaab3cc1f01d385b399faf85e46b8 Mon Sep 17 00:00:00 2001 From: Janis Goldschmidt Date: Thu, 18 Feb 2021 13:03:10 +0100 Subject: [PATCH] Fix Json extractor to be 32kB by default While technically the default limit for `JsonBody` is indeed 256kB when called through `JsonBody::new`, in practice the limit is always set to 32kB for every context where `JsonBody` is used (via `JsonConfig`). This is also consistent with the documentation of the `JsonError::Overflow`, which mentions a default maximum of `32kB`. This commit changes the default to also be `32kB` instead of `256kB`. --- CHANGES.md | 3 +++ src/types/json.rs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 743f5066b..7cb03c30c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,8 +3,11 @@ ## Unreleased - 2021-xx-xx ### Changed * Feature `cookies` is now optional and enabled by default. [#1981] +* `JsonBody::new` returns a default limit of 32kB to be consistent with `JsonConfig` and the + default behaviour of the `web::Json` extractor. [#2010] [#1981]: https://github.com/actix/actix-web/pull/1981 +[#2010]: https://github.com/actix/actix-web/pull/2010 ## 4.0.0-beta.3 - 2021-02-10 diff --git a/src/types/json.rs b/src/types/json.rs index 28960402a..31ff680f4 100644 --- a/src/types/json.rs +++ b/src/types/json.rs @@ -345,7 +345,7 @@ where let payload = payload.take(); JsonBody::Body { - limit: 262_144, + limit: 32_768, length, payload, buf: BytesMut::with_capacity(8192), @@ -353,7 +353,7 @@ where } } - /// Set maximum accepted payload size. The default limit is 256kB. + /// Set maximum accepted payload size. The default limit is 32kB. pub fn limit(self, limit: usize) -> Self { match self { JsonBody::Body {