Added support for encoded payload

Actix provides different content encodings out of the box, but only if we use built-in content wrappers and containers. This patch wraps its own Payload implementation with an actix decoder, which enables request compression support.
This commit is contained in:
Andrey "MOU" Larionov
2022-10-09 21:55:14 +02:00
parent 11b986a81d
commit 9dbc71cb6d
3 changed files with 138 additions and 2 deletions

View File

@ -1,6 +1,7 @@
use crate::common::{GetAllDocumentsOptions, Server};
use serde_json::json;
use crate::common::encoder::Encoder;
#[actix_rt::test]
async fn error_document_update_create_index_bad_uid() {
@ -89,6 +90,47 @@ async fn update_document() {
);
}
#[actix_rt::test]
async fn update_document_gzip_encoded() {
let server = Server::new().await;
let index = server.index_with_encoder("test", Encoder::Gzip);
let documents = json!([
{
"doc_id": 1,
"content": "foo",
}
]);
let (_response, code) = index.add_documents(documents, None).await;
assert_eq!(code, 202);
index.wait_task(0).await;
let documents = json!([
{
"doc_id": 1,
"other": "bar",
}
]);
let (response, code) = index.update_documents(documents, None).await;
assert_eq!(code, 202, "response: {}", response);
index.wait_task(1).await;
let (response, code) = index.get_task(1).await;
assert_eq!(code, 200);
assert_eq!(response["status"], "succeeded");
let (response, code) = index.get_document(1, None).await;
assert_eq!(code, 200);
assert_eq!(
response.to_string(),
r##"{"doc_id":1,"content":"foo","other":"bar"}"##
);
}
#[actix_rt::test]
async fn update_larger_dataset() {
let server = Server::new().await;