mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 08:41:00 +00:00
fix the payload too large error
This commit is contained in:
committed by
Clément Renault
parent
1bef5d119d
commit
e107f1b282
@ -2,11 +2,12 @@ use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use actix_http::encoding::Decoder as Decompress;
|
||||
use actix_web::error::PayloadError;
|
||||
use actix_web::{dev, web, FromRequest, HttpRequest};
|
||||
use futures::future::{ready, Ready};
|
||||
use futures::Stream;
|
||||
|
||||
use crate::error::MeilisearchHttpError;
|
||||
|
||||
pub struct Payload {
|
||||
payload: Decompress<dev::Payload>,
|
||||
limit: usize,
|
||||
@ -29,7 +30,7 @@ impl Default for PayloadConfig {
|
||||
}
|
||||
|
||||
impl FromRequest for Payload {
|
||||
type Error = PayloadError;
|
||||
type Error = MeilisearchHttpError;
|
||||
|
||||
type Future = Ready<Result<Payload, Self::Error>>;
|
||||
|
||||
@ -47,7 +48,7 @@ impl FromRequest for Payload {
|
||||
}
|
||||
|
||||
impl Stream for Payload {
|
||||
type Item = Result<web::Bytes, PayloadError>;
|
||||
type Item = Result<web::Bytes, MeilisearchHttpError>;
|
||||
|
||||
#[inline]
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
@ -58,11 +59,11 @@ impl Stream for Payload {
|
||||
self.limit = new_limit;
|
||||
Poll::Ready(Some(Ok(bytes)))
|
||||
}
|
||||
None => Poll::Ready(Some(Err(PayloadError::Overflow))),
|
||||
None => Poll::Ready(Some(Err(MeilisearchHttpError::PayloadTooLarge))),
|
||||
},
|
||||
x => Poll::Ready(Some(x)),
|
||||
x => Poll::Ready(Some(x.map_err(MeilisearchHttpError::from))),
|
||||
},
|
||||
otherwise => otherwise,
|
||||
otherwise => otherwise.map(|o| o.map(|o| o.map_err(MeilisearchHttpError::from))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user