Skip to content

Commit

Permalink
Fix Json extractor to be 32kB by default
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
SuperFluffy committed Feb 18, 2021
1 parent 1838d9c commit 0501193
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>` 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
Expand Down
4 changes: 2 additions & 2 deletions src/types/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,15 @@ where
let payload = payload.take();

JsonBody::Body {
limit: 262_144,
limit: 32_768,
length,
payload,
buf: BytesMut::with_capacity(8192),
_res: PhantomData,
}
}

/// 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 {
Expand Down

0 comments on commit 0501193

Please sign in to comment.