[MINOR] checks: make the HTTP check code add the CRLF itself
Currently we cannot easily add headers nor anything to HTTP checks
because the requests are pre-formatted with the last CRLF. Make the
check code add the CRLF itself so that we can later add useful info.
diff --git a/src/checks.c b/src/checks.c
index 50e3190..3f6fa90 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -664,6 +664,9 @@
(s->proxy->options & PR_O_SMTP_CHK) ||
(s->proxy->options2 & PR_O2_MYSQL_CHK)) {
int ret;
+ const char *check_req = s->proxy->check_req;
+ int check_len = s->proxy->check_len;
+
/* we want to check if this host replies to HTTP or SSLv3 requests
* so we'll send the request, and won't wake the checker up now.
*/
@@ -673,9 +676,16 @@
int gmt_time = htonl(date.tv_sec);
memcpy(s->proxy->check_req + 11, &gmt_time, 4);
}
+ else if (s->proxy->options & PR_O_HTTP_CHK) {
+ memcpy(trash, check_req, check_len);
+ trash[check_len++] = '\r';
+ trash[check_len++] = '\n';
+ trash[check_len] = '\0';
+ check_req = trash;
+ }
- ret = send(fd, s->proxy->check_req, s->proxy->check_len, MSG_DONTWAIT | MSG_NOSIGNAL);
- if (ret == s->proxy->check_len) {
+ ret = send(fd, check_req, check_len, MSG_DONTWAIT | MSG_NOSIGNAL);
+ if (ret == check_len) {
/* we allow up to <timeout.check> if nonzero for a responce */
if (s->proxy->timeout.check)
t->expire = tick_add_ifset(now_ms, s->proxy->timeout.check);