From 36e46aa28ca902ffa3eae93a23208da7c3bc09d7 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 28 Sep 2021 11:45:05 +0200 Subject: [PATCH] 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. --- src/mux_h1.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mux_h1.c b/src/mux_h1.c index 285754548..7d7158f82 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: