mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-23 21:20:24 +01:00
Merge #4450
4450: Add the content type in the webhook + improve the test r=Kerollmops a=irevoire # Pull Request ## Related issue Fixes https://github.com/meilisearch/meilisearch/issues/4436 ## What does this PR do? - Specify the content type of the webhook - Ensure it’s the case in the test Co-authored-by: Tamo <tamo@meilisearch.com>
This commit is contained in:
commit
bdd428c22e
@ -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,
|
||||
|
@ -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<mpsc::UnboundedSender<Vec<u8>>>, body: Bytes) -> HttpResponse {
|
||||
async fn forward_body(
|
||||
req: HttpRequest,
|
||||
sender: Data<mpsc::UnboundedSender<Vec<u8>>>,
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user