From: Christopher Faulet Date: Tue, 28 Sep 2021 09:45:05 +0000 (+0200) Subject: MINOR: mux-h1: Set error code if possible when MUX_EXIT_STATUS is returned X-Git-Tag: v2.5-dev9~153 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36e46aa28ca902ffa3eae93a23208da7c3bc09d7;p=thirdparty%2Fhaproxy.git MINOR: mux-h1: Set error code if possible when MUX_EXIT_STATUS is returned 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. --- diff --git a/src/mux_h1.c b/src/mux_h1.c index 2857545489..7d7158f82d 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -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: