BUG/MINOR: http-check: Skip C-L header for empty body when it's not mandatory
The Content-Length header is always added into the request for an HTTP health-check. However, when there is no payload, this header may be skipped for OPTIONS, GET, HEAD and DELETE methods. In fact, it is a "SHOULD NOT" in the RCF 9110 (#8.6). It is not really an issue in itself but it seems to be an issue for AWS ELB. It returns a 400-Bad-Request if a HEAD/GET request with no payload contains a Content-Length header. So, it is better to skip this header when possible. This patch should fix the issue #2026. It could be backported as far as 2.2.
This commit is contained in:
parent
0506d9de51
commit
d48bfb6983
@ -1459,12 +1459,18 @@ enum tcpcheck_eval_ret tcpcheck_eval_send(struct check *check, struct tcpcheck_r
|
||||
}
|
||||
else
|
||||
body = send->http.body;
|
||||
clen = ist((!istlen(body) ? "0" : ultoa(istlen(body))));
|
||||
|
||||
if ((!connection_hdr && !htx_add_header(htx, ist("Connection"), ist("close"))) ||
|
||||
!htx_add_header(htx, ist("Content-length"), clen))
|
||||
if (!connection_hdr && !htx_add_header(htx, ist("Connection"), ist("close")))
|
||||
goto error_htx;
|
||||
|
||||
if ((send->http.meth.meth != HTTP_METH_OPTIONS &&
|
||||
send->http.meth.meth != HTTP_METH_GET &&
|
||||
send->http.meth.meth != HTTP_METH_HEAD &&
|
||||
send->http.meth.meth != HTTP_METH_DELETE) || istlen(body)) {
|
||||
clen = ist((!istlen(body) ? "0" : ultoa(istlen(body))));
|
||||
if (!htx_add_header(htx, ist("Content-length"), clen))
|
||||
goto error_htx;
|
||||
}
|
||||
|
||||
if (!htx_add_endof(htx, HTX_BLK_EOH) ||
|
||||
(istlen(body) && !htx_add_data_atonce(htx, body)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user