diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index 9544004cc..adb3d4942 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -1395,7 +1395,9 @@ impl IndexScheduler { // let reader = GzEncoder::new(BufReader::new(task_reader), Compression::default()); let reader = GzEncoder::new(BufReader::new(task_reader), Compression::default()); - let request = ureq::post(url).set("Content-Encoding", "gzip"); + let request = ureq::post(url) + .set("Content-Encoding", "gzip") + .set("Content-Type", "application/x-ndjson"); let request = match &self.webhook_authorization_header { Some(header) => request.set("Authorization", header), None => request, diff --git a/meilisearch/tests/tasks/webhook.rs b/meilisearch/tests/tasks/webhook.rs index a18a93edb..b01ef3d5a 100644 --- a/meilisearch/tests/tasks/webhook.rs +++ b/meilisearch/tests/tasks/webhook.rs @@ -7,7 +7,7 @@ use std::sync::Arc; use actix_http::body::MessageBody; use actix_web::dev::{ServiceFactory, ServiceResponse}; use actix_web::web::{Bytes, Data}; -use actix_web::{post, App, HttpResponse, HttpServer}; +use actix_web::{post, App, HttpRequest, HttpResponse, HttpServer}; use meili_snap::{json_string, snapshot}; use meilisearch::Opt; use tokio::sync::mpsc; @@ -17,7 +17,17 @@ use crate::common::{default_settings, Server}; use crate::json; #[post("/")] -async fn forward_body(sender: Data>>, body: Bytes) -> HttpResponse { +async fn forward_body( + req: HttpRequest, + sender: Data>>, + body: Bytes, +) -> HttpResponse { + let headers = req.headers(); + assert_eq!(headers.get("content-type").unwrap(), "application/x-ndjson"); + assert_eq!(headers.get("transfer-encoding").unwrap(), "chunked"); + assert_eq!(headers.get("accept-encoding").unwrap(), "gzip"); + assert_eq!(headers.get("content-encoding").unwrap(), "gzip"); + let body = body.to_vec(); sender.send(body).unwrap(); HttpResponse::Ok().into()