summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_request.c
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2023-03-18 16:32:59 +0000
committerAndrew Clayton <a.clayton@nginx.com>2023-04-25 13:59:43 +0100
commit1a485fed6a8353ecc09e6c0f050e44c0a2d30419 (patch)
tree7d8b6360f9908a37b0667a173e357c78fd7fd5ff /src/nxt_http_request.c
parent1fd6eb626baeee94a65b199cd848019e0e6b81b3 (diff)
downloadunit-1a485fed6a8353ecc09e6c0f050e44c0a2d30419.tar.gz
unit-1a485fed6a8353ecc09e6c0f050e44c0a2d30419.tar.bz2
Allow to remove the version string in HTTP responses.
Normally Unit responds to HTTP requests by including a header like Server: Unit/1.30.0 however it can sometimes be beneficial to withhold the version information and in this case just respond with Server: Unit This patch adds a new "settings.http" boolean option called server_version, which defaults to true, in which case the full version information is sent. However this can be set to false, e.g "settings": { "http": { "server_version": false } }, in which case Unit responds without the version information as the latter example above shows. Link: <https://www.ietf.org/rfc/rfc9110.html#section-10.2.4> Closes: <https://github.com/nginx/unit/issues/158> Reviewed-by: Alejandro Colomar <alx@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'src/nxt_http_request.c')
-rw-r--r--src/nxt_http_request.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/nxt_http_request.c b/src/nxt_http_request.c
index e78975aa..e53b1ec8 100644
--- a/src/nxt_http_request.c
+++ b/src/nxt_http_request.c
@@ -622,8 +622,9 @@ void
nxt_http_request_header_send(nxt_task_t *task, nxt_http_request_t *r,
nxt_work_handler_t body_handler, void *data)
{
- u_char *p, *end;
- nxt_http_field_t *server, *date, *content_length;
+ u_char *p, *end, *server_string;
+ nxt_http_field_t *server, *date, *content_length;
+ nxt_socket_conf_t *skcf;
/*
* TODO: "Server", "Date", and "Content-Length" processing should be moved
@@ -635,7 +636,12 @@ nxt_http_request_header_send(nxt_task_t *task, nxt_http_request_t *r,
goto fail;
}
- nxt_http_field_set(server, "Server", NXT_SERVER);
+ skcf = r->conf->socket_conf;
+ server_string = (u_char *) (skcf->server_version ? NXT_SERVER : NXT_NAME);
+
+ nxt_http_field_name_set(server, "Server");
+ server->value = server_string;
+ server->value_length = nxt_strlen(server_string);
if (r->resp.date == NULL) {
date = nxt_list_zero_add(r->resp.fields);