MINOR: check: do not ignore a connection header for http-check send
Allow the user to specify a custom Connection header for http-check
send. This is useful for example to implement a websocket upgrade check.
If no connection header has been set, a 'Connection: close' header is
automatically appended to allow the server to close the connection
immediately after the request/response.
Update the documentation related to http-check send.
This fixes the github issue #1009.
(cherry picked from commit 6d975f0af650e51c5c8e584d9b6beb413deb6868)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/tcpcheck.c b/src/tcpcheck.c
index 1e39648..7e972a1 100644
--- a/src/tcpcheck.c
+++ b/src/tcpcheck.c
@@ -1216,6 +1216,7 @@
struct connection *conn = cs_conn(cs);
struct buffer *tmp = NULL;
struct htx *htx = NULL;
+ int connection_hdr = 0;
if (check->state & CHK_ST_OUT_ALLOC) {
ret = TCPCHK_EVAL_WAIT;
@@ -1319,6 +1320,8 @@
if (!http_update_authority(htx, sl, hdr_value))
goto error_htx;
}
+ if (isteqi(hdr->name, ist("connection")))
+ connection_hdr = 1;
}
}
@@ -1339,7 +1342,7 @@
body = send->http.body;
clen = ist((!istlen(body) ? "0" : ultoa(istlen(body))));
- if (!htx_add_header(htx, ist("Connection"), ist("close")) ||
+ if ((!connection_hdr && !htx_add_header(htx, ist("Connection"), ist("close"))) ||
!htx_add_header(htx, ist("Content-length"), clen))
goto error_htx;
@@ -2556,8 +2559,7 @@
}
host_hdr = i;
}
- else if (strcasecmp(args[cur_arg+1], "connection") == 0 ||
- strcasecmp(args[cur_arg+1], "content-length") == 0 ||
+ else if (strcasecmp(args[cur_arg+1], "content-length") == 0 ||
strcasecmp(args[cur_arg+1], "transfer-encoding") == 0)
goto skip_hdr;