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.
This commit is contained in:
Christopher Faulet 2021-09-28 11:45:05 +02:00
parent a015b3ec8b
commit 36e46aa28c

View 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 :
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: