diff --git a/Cargo.lock b/Cargo.lock index ab566e836..e632d8621 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1680,9 +1680,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.26" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "miniz_oxide", @@ -2777,6 +2777,7 @@ dependencies = [ "dump", "enum-iterator", "file-store", + "flate2", "insta", "log", "meili-snap", diff --git a/index-scheduler/Cargo.toml b/index-scheduler/Cargo.toml index 4d6e4ffd0..a8c19f435 100644 --- a/index-scheduler/Cargo.toml +++ b/index-scheduler/Cargo.toml @@ -18,6 +18,7 @@ derive_builder = "0.12.0" dump = { path = "../dump" } enum-iterator = "1.4.0" file-store = { path = "../file-store" } +flate2 = "1.0.28" log = "0.4.17" meilisearch-auth = { path = "../meilisearch-auth" } meilisearch-types = { path = "../meilisearch-types" } diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index 5d44ed104..bfaca3126 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -45,6 +45,8 @@ use dump::{KindDump, TaskDump, UpdateFile}; pub use error::Error; pub use features::RoFeatures; use file_store::FileStore; +use flate2::bufread::GzEncoder; +use flate2::Compression; use meilisearch_types::error::ResponseError; use meilisearch_types::features::{InstanceTogglableFeatures, RuntimeTogglableFeatures}; use meilisearch_types::heed::byteorder::BE; @@ -1288,7 +1290,10 @@ impl IndexScheduler { buffer.push(b'\n'); } - let _ = ureq::post(url).send_bytes(&buffer).unwrap(); + let reader = GzEncoder::new(&buffer[..], Compression::default()); + if let Err(e) = ureq::post(url).set("Content-Encoding", "gzip").send(reader) { + log::error!("While sending data to the webhook: {e}"); + } } Ok(()) diff --git a/meilisearch/tests/tasks/webhook.rs b/meilisearch/tests/tasks/webhook.rs index e852839ec..688d35e8b 100644 --- a/meilisearch/tests/tasks/webhook.rs +++ b/meilisearch/tests/tasks/webhook.rs @@ -11,6 +11,7 @@ use actix_web::{post, App, HttpResponse, HttpServer}; use meili_snap::{json_string, snapshot}; use meilisearch::Opt; use tokio::sync::mpsc; +use url::Url; use crate::common::{default_settings, Server}; use crate::json; @@ -66,7 +67,7 @@ async fn test_basic_webhook() { let db_path = tempfile::tempdir().unwrap(); let server = Server::new_with_options(Opt { - task_webhook_url: Some(url), + task_webhook_url: Some(Url::parse(&url).unwrap()), ..default_settings(db_path.path()) }) .await