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 6d26793
Showing 1 changed file with 2 additions and 2 deletions.
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 6d26793

Please sign in to comment.