From 1299d6118f8f876178d04eb8e14aaaa8dc1d09c7 Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov Date: Thu, 17 May 2018 16:00:09 +0100 Subject: [PATCH] Add MG_HIDE_SERVER_INFO Closes https://github.com/cesanta/mos-libs/pull/2 CL: Add MG_HIDE_SERVER_INFO PUBLISHED_FROM=ed8a5b65f1c8238df414cd1c1f8bb1f579082f55 --- mongoose.c | 7 +++++-- src/mg_http.c | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mongoose.c b/mongoose.c index 18c1b642..82aebae8 100644 --- a/mongoose.c +++ b/mongoose.c @@ -6872,8 +6872,11 @@ const char *mg_status_message(int status_code) { void mg_send_response_line_s(struct mg_connection *nc, int status_code, const struct mg_str extra_headers) { - mg_printf(nc, "HTTP/1.1 %d %s\r\nServer: %s\r\n", status_code, - mg_status_message(status_code), mg_version_header); + mg_printf(nc, "HTTP/1.1 %d %s\r\n", status_code, + mg_status_message(status_code)); +#ifndef MG_HIDE_SERVER_INFO + mg_printf(nc, "Server: %s\r\n", mg_version_header); +#endif if (extra_headers.len > 0) { mg_printf(nc, "%.*s\r\n", (int) extra_headers.len, extra_headers.p); } diff --git a/src/mg_http.c b/src/mg_http.c index 57531c96..e7151aca 100644 --- a/src/mg_http.c +++ b/src/mg_http.c @@ -1311,8 +1311,11 @@ const char *mg_status_message(int status_code) { void mg_send_response_line_s(struct mg_connection *nc, int status_code, const struct mg_str extra_headers) { - mg_printf(nc, "HTTP/1.1 %d %s\r\nServer: %s\r\n", status_code, - mg_status_message(status_code), mg_version_header); + mg_printf(nc, "HTTP/1.1 %d %s\r\n", status_code, + mg_status_message(status_code)); +#ifndef MG_HIDE_SERVER_INFO + mg_printf(nc, "Server: %s\r\n", mg_version_header); +#endif if (extra_headers.len > 0) { mg_printf(nc, "%.*s\r\n", (int) extra_headers.len, extra_headers.p); }