From 352f3b9ef08eca3d09720408d3f91808553e8a4e Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Tue, 8 Sep 2020 11:31:22 +0200 Subject: [PATCH] prefix Content-Length by X- to avoid issues with chunked encoding closes #350 --- http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/http.c b/http.c index 2cc174e..a3bb1dd 100644 --- a/http.c +++ b/http.c @@ -364,7 +364,7 @@ static int json_response(struct mg_connection *conn, JsonNode *json) mg_send_header(conn, "Access-Control-Allow-Origin", "*"); if (json == NULL) { - mg_send_header(conn, "Content-Length", "2"); + mg_send_header(conn, "X-Content-Length", "2"); mg_printf_data(conn, "{}"); } else { if ((js = json_stringify(json, JSON_INDENT)) != NULL) { @@ -372,7 +372,7 @@ static int json_response(struct mg_connection *conn, JsonNode *json) int length = snprintf(NULL, 0, "%zu", content_length); char buffer[length + 1]; snprintf(buffer, length + 1, "%zu", content_length); - mg_send_header(conn, "Content-Length", buffer); + mg_send_header(conn, "X-Content-Length", buffer); mg_printf_data(conn, js); free(js); }