diff --git a/meilisearch/src/extractors/payload.rs b/meilisearch/src/extractors/payload.rs index d43778d5d..5e7e9cf7e 100644 --- a/meilisearch/src/extractors/payload.rs +++ b/meilisearch/src/extractors/payload.rs @@ -11,6 +11,7 @@ use crate::error::MeilisearchHttpError; pub struct Payload { payload: Decompress, limit: usize, + remaining: usize, } pub struct PayloadConfig { @@ -43,6 +44,7 @@ impl FromRequest for Payload { ready(Ok(Payload { payload: Decompress::from_headers(payload.take(), req.headers()), limit, + remaining: limit, })) } } @@ -54,9 +56,9 @@ impl Stream for Payload { fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { match Pin::new(&mut self.payload).poll_next(cx) { Poll::Ready(Some(result)) => match result { - Ok(bytes) => match self.limit.checked_sub(bytes.len()) { + Ok(bytes) => match self.remaining.checked_sub(bytes.len()) { Some(new_limit) => { - self.limit = new_limit; + self.remaining = new_limit; Poll::Ready(Some(Ok(bytes))) } None => {