]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h1: Set error code if possible when MUX_EXIT_STATUS is returned
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 28 Sep 2021 09:45:05 +0000 (11:45 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 28 Sep 2021 14:17:59 +0000 (16:17 +0200)
In h1_ctl(), if output parameter is provided when MUX_EXIT_STATUS is
returned, it is used to set the error code. In addition, any client errors
(4xx), except for 408 ones, are handled as invalid errors
(MUX_ES_INVALID_ERR). This way, it will be possible to customize the parsing
error code for request messages.

src/mux_h1.c

index 28575454892983f367bd9b9eba6ab22e9827b256..7d7158f82dec658941c6d1e6c4c16fd3c0cf7a9d 100644 (file)
@@ -3541,10 +3541,12 @@ static int h1_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *outp
                        ret |= MUX_STATUS_READY;
                return ret;
        case MUX_EXIT_STATUS:
-               ret = (h1c->errcode == 400 ? MUX_ES_INVALID_ERR :
-                      (h1c->errcode == 408 ? MUX_ES_TOUT_ERR :
-                       (h1c->errcode == 501 ? MUX_ES_NOTIMPL_ERR :
-                        (h1c->errcode == 500 ? MUX_ES_INTERNAL_ERR :
+               if (output)
+                       *((int *)output) = h1c->errcode;
+               ret = (h1c->errcode == 408 ? MUX_ES_TOUT_ERR :
+                      (h1c->errcode == 501 ? MUX_ES_NOTIMPL_ERR :
+                       (h1c->errcode == 500 ? MUX_ES_INTERNAL_ERR :
+                        ((h1c->errcode >= 400 && h1c->errcode <= 499) ? MUX_ES_INVALID_ERR :
                          MUX_ES_SUCCESS))));
                return ret;
        default: