MINOR: http-check: Remove support for headers/body in "option httpchk" version
This trick is deprecated since the health-check refactoring, It is now
invalid. It means the following line will trigger an error during the
configuration parsing:
option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www
It must be replaced by:
option httpchk OPTIONS * HTTP/1.1
http-check send hdr Host www
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 8e95b0b..f1fc0bb 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -9247,11 +9247,6 @@
internally relies on an HTX multiplexer. Thus, it means the request
formatting and the response parsing will be strict.
- Note : For a while, there was no way to add headers or body in the request
- used for HTTP health checks. So a workaround was to hide it at the end
- of the version string with a "\r\n" after the version. It is now
- deprecated. The directive "http-check send" must be used instead.
-
Examples :
# Relay HTTPS traffic to Apache instance and check service availability
# using HTTP request "OPTIONS * HTTP/1.1" on port 80.
diff --git a/reg-tests/checks/4be_1srv_smtpchk_httpchk_layer47errors.vtc b/reg-tests/checks/4be_1srv_smtpchk_httpchk_layer47errors.vtc
index 5286bdb..2e98a3f 100644
--- a/reg-tests/checks/4be_1srv_smtpchk_httpchk_layer47errors.vtc
+++ b/reg-tests/checks/4be_1srv_smtpchk_httpchk_layer47errors.vtc
@@ -65,7 +65,8 @@
backend be2
mode tcp
log ${S2_addr}:${S2_port} daemon
- option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www
+ option httpchk OPTIONS * HTTP/1.1
+ http-check send hdr Host www
server srv2 ${s2_addr}:${s2_port} check
backend be3
diff --git a/reg-tests/checks/http-check-send.vtc b/reg-tests/checks/http-check-send.vtc
index 0970ee4..530ad75 100644
--- a/reg-tests/checks/http-check-send.vtc
+++ b/reg-tests/checks/http-check-send.vtc
@@ -28,7 +28,6 @@
expect req.method == OPTIONS
expect req.url == /
expect req.proto == HTTP/1.0
- expect req.http.hdr == <undef>
expect req.http.host == <undef>
expect req.http.x-test == <undef>
expect req.bodylen == 0
@@ -41,7 +40,6 @@
expect req.url == /status
expect req.proto == HTTP/1.1
expect req.http.connection == "close"
- expect req.http.hdr == <undef>
expect req.http.host == "my-www-host"
expect req.http.x-test == true
expect req.http.content-length == 4
@@ -55,7 +53,6 @@
expect req.method == OPTIONS
expect req.url == /
expect req.proto == HTTP/1.0
- expect req.http.hdr == <undef>
expect req.http.host == "other-www-host"
expect req.http.x-test == <undef>
expect req.http.x-new-test == true
@@ -134,7 +131,7 @@
timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
- option httpchk GET /status HTTP/1.1\r\nHdr:\ must-be-removed
+ option httpchk GET /status HTTP/1.1
option log-health-checks
http-check send hdr Host "my-www-host" hdr X-test true body "test"
diff --git a/reg-tests/checks/tls_health_checks.vtc b/reg-tests/checks/tls_health_checks.vtc
index 1989d65..9c268f4 100644
--- a/reg-tests/checks/tls_health_checks.vtc
+++ b/reg-tests/checks/tls_health_checks.vtc
@@ -95,7 +95,8 @@
backend be2
option log-health-checks
- option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www
+ option httpchk OPTIONS * HTTP/1.1
+ http-check send hdr Host www
log ${S2_addr}:${S2_port} daemon
server srv1 ${h1_fe1_addr}:${h1_fe1_port} ssl crt ${testdir}/common.pem verify none check
@@ -106,7 +107,8 @@
backend be6
option log-health-checks
- option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www
+ option httpchk OPTIONS * HTTP/1.1
+ http-check send hdr Host www
log ${S6_addr}:${S6_port} daemon
server srv3 127.0.0.1:80 crt ${testdir}/common.pem verify none check check-ssl port ${h1_fe3_port} addr ${h1_fe3_addr}:80
} -start
diff --git a/src/tcpcheck.c b/src/tcpcheck.c
index e597cf8..fc5197d 100644
--- a/src/tcpcheck.c
+++ b/src/tcpcheck.c
@@ -4915,19 +4915,10 @@
hdrs = (*args[cur_arg+2] ? strstr(args[cur_arg+2], "\r\n") : NULL);
body = (*args[cur_arg+2] ? strstr(args[cur_arg+2], "\r\n\r\n") : NULL);
- if (hdrs == body)
- hdrs = NULL;
- if (hdrs) {
- *hdrs = '\0';
- hdrs +=2;
- }
- if (body) {
- *body = '\0';
- body += 4;
- }
if (hdrs || body) {
- memprintf(errmsg, "hiding headers or body at the end of the version string is deprecated."
- " Please, consider to use 'http-check send' directive instead.");
+ memprintf(errmsg, "hiding headers or body at the end of the version string is unsupported."
+ "Use 'http-check send' directive instead.");
+ goto error;
}
chk = calloc(1, sizeof(*chk));
@@ -4977,53 +4968,6 @@
}
}
- /* Copy the header */
- if (hdrs) {
- struct http_hdr tmp_hdrs[global.tune.max_http_hdr];
- struct h1m h1m;
- int i, ret;
-
- /* Build and parse the request */
- chunk_printf(&trash, "%s\r\n\r\n", hdrs);
-
- h1m.flags = H1_MF_HDRS_ONLY;
- ret = h1_headers_to_hdr_list(b_orig(&trash), b_tail(&trash),
- tmp_hdrs, sizeof(tmp_hdrs)/sizeof(tmp_hdrs[0]),
- &h1m, NULL);
- if (ret <= 0) {
- memprintf(errmsg, "unable to parse the request '%s'.", b_orig(&trash));
- goto error;
- }
-
- for (i = 0; istlen(tmp_hdrs[i].n); i++) {
- hdr = calloc(1, sizeof(*hdr));
- if (!hdr) {
- memprintf(errmsg, "out of memory");
- goto error;
- }
- LIST_INIT(&hdr->value);
- hdr->name = istdup(tmp_hdrs[i].n);
- if (!isttest(hdr->name)) {
- memprintf(errmsg, "out of memory");
- goto error;
- }
-
- ist0(tmp_hdrs[i].v);
- if (!parse_logformat_string(istptr(tmp_hdrs[i].v), px, &hdr->value, 0, SMP_VAL_BE_CHK_RUL, errmsg))
- goto error;
- LIST_APPEND(&chk->send.http.hdrs, &hdr->list);
- }
- }
-
- /* Copy the body */
- if (body) {
- chk->send.http.body = ist(strdup(body));
- if (!isttest(chk->send.http.body)) {
- memprintf(errmsg, "out of memory");
- goto error;
- }
- }
-
return chk;
error: