2876: Full support for compressed (Gzip, Brotli, Zlib) API requests r=Kerollmops a=mou

# Pull Request

## Related issue
Fixes #2802 

## What does this PR do?
- Adds missed content-encoding support for streamed requests (documents)
- Adds additional tests to validate content-encoding support is in place
- Adds new tests to validate content-encoding support for previously existing code (built-in actix functionality for unmarshaling JSON payloads)

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Co-authored-by: Andrey "MOU" Larionov <anlarionov@gmail.com>
This commit is contained in:
bors[bot] 2022-10-13 15:32:21 +00:00 committed by GitHub
commit fc5a7e376c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 650 additions and 293 deletions

View file

@ -1,13 +1,14 @@
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;
pub struct Payload {
payload: dev::Payload,
payload: Decompress<dev::Payload>,
limit: usize,
}
@ -39,7 +40,7 @@ impl FromRequest for Payload {
.map(|c| c.limit)
.unwrap_or(PayloadConfig::default().limit);
ready(Ok(Payload {
payload: payload.take(),
payload: Decompress::from_headers(payload.take(), req.headers()),
limit,
}))
}