From 3529bbb13236d8127df60be027543ec9212268b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 15 Apr 2024 17:49:06 +0200 Subject: [PATCH] out_http: Use x-ndjson content type for json_lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel RĂ¼ger --- plugins/out_http/http.c | 8 +++++++- plugins/out_http/http.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/out_http/http.c b/plugins/out_http/http.c index d804b7734f6..17840975309 100644 --- a/plugins/out_http/http.c +++ b/plugins/out_http/http.c @@ -178,7 +178,6 @@ static int http_post(struct flb_out_http *ctx, } else if ((ctx->out_format == FLB_PACK_JSON_FORMAT_JSON) || (ctx->out_format == FLB_PACK_JSON_FORMAT_STREAM) || - (ctx->out_format == FLB_PACK_JSON_FORMAT_LINES) || (ctx->out_format == FLB_HTTP_OUT_GELF)) { flb_http_add_header(c, FLB_HTTP_CONTENT_TYPE, @@ -186,6 +185,13 @@ static int http_post(struct flb_out_http *ctx, FLB_HTTP_MIME_JSON, sizeof(FLB_HTTP_MIME_JSON) - 1); } + else if ((ctx->out_format == FLB_PACK_JSON_FORMAT_LINES)) { + flb_http_add_header(c, + FLB_HTTP_CONTENT_TYPE, + sizeof(FLB_HTTP_CONTENT_TYPE) - 1, + FLB_HTTP_MIME_NDJSON, + sizeof(FLB_HTTP_MIME_NDJSON) - 1); + } else if ((ctx->out_format == FLB_HTTP_OUT_MSGPACK)) { flb_http_add_header(c, FLB_HTTP_CONTENT_TYPE, diff --git a/plugins/out_http/http.h b/plugins/out_http/http.h index 585e51cb40f..ba588ac90ca 100644 --- a/plugins/out_http/http.h +++ b/plugins/out_http/http.h @@ -26,6 +26,7 @@ #define FLB_HTTP_CONTENT_TYPE "Content-Type" #define FLB_HTTP_MIME_MSGPACK "application/msgpack" #define FLB_HTTP_MIME_JSON "application/json" +#define FLB_HTTP_MIME_NDJSON "application/x-ndjson" #ifdef FLB_HAVE_SIGNV4 #ifdef FLB_HAVE_AWS