]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h1: Obey dontlognull option for empty requests
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 26 Jul 2021 07:42:49 +0000 (09:42 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 26 Jul 2021 13:14:35 +0000 (15:14 +0200)
If a H1 connection is closed while no data are received, if the dontlognull
option is set, no log message must be emitted. Because the H1 multiplexer
handles early errors, it must take care to obey this option. It is true for
400-Bad-Request, 408-Request-Time-out and 501-Not-Implemented
responses. 500-Internal-Server-Error responses are still logged.

This patch should fix the issue #1336 for H1 sessions. It must be backported
to 2.4.

src/mux_h1.c

index 537f0f999cac8a89256797a1e81a1c464b575223..bed2e03fab34be259db8a2c067c433df47a389e2 100644 (file)
@@ -2427,7 +2427,8 @@ static int h1_handle_bad_req(struct h1c *h1c)
 
        h1c->errcode = 400;
        ret = h1_send_error(h1c);
-       sess_log(sess);
+       if (b_data(&h1c->ibuf) || !(sess->fe->options & PR_O_NULLNOLOG))
+               sess_log(sess);
 
   end:
        return ret;
@@ -2454,7 +2455,8 @@ static int h1_handle_not_impl_err(struct h1c *h1c)
 
        h1c->errcode = 501;
        ret = h1_send_error(h1c);
-       sess_log(sess);
+       if (b_data(&h1c->ibuf) || !(sess->fe->options & PR_O_NULLNOLOG))
+               sess_log(sess);
 
   end:
        return ret;
@@ -2479,7 +2481,8 @@ static int h1_handle_req_tout(struct h1c *h1c)
                _HA_ATOMIC_INC(&sess->listener->counters->failed_req);
 
        h1c->errcode = 408;
-       ret = h1_send_error(h1c);
+       if (b_data(&h1c->ibuf) || !(sess->fe->options & PR_O_NULLNOLOG))
+               ret = h1_send_error(h1c);
        sess_log(sess);
   end:
        return ret;