From: Willy Tarreau Date: Sun, 24 Nov 2019 13:56:03 +0000 (+0100) Subject: MINOR: h2: add a function to report H2 error codes as strings X-Git-Tag: v2.1.0~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c22d5dfeb87057e54bb28069a0f79565261802cb;p=thirdparty%2Fhaproxy.git MINOR: h2: add a function to report H2 error codes as strings Just like we have frame type to string, let's have error to string to improve debugging and traces. --- diff --git a/include/common/h2.h b/include/common/h2.h index 1e0cf5ee8b..03582992a4 100644 --- a/include/common/h2.h +++ b/include/common/h2.h @@ -233,6 +233,28 @@ static inline const char *h2_ft_str(int type) } } +/* returns the error code as a string */ +static inline const char *h2_err_str(enum h2_err err) +{ + switch (err) { + case H2_ERR_NO_ERROR : return "NO_ERROR"; + case H2_ERR_PROTOCOL_ERROR : return "PROTOCOL_ERROR"; + case H2_ERR_INTERNAL_ERROR : return "INTERNAL_ERROR"; + case H2_ERR_FLOW_CONTROL_ERROR : return "FLOW_CONTROL_ERROR"; + case H2_ERR_SETTINGS_TIMEOUT : return "SETTINGS_TIMEOUT"; + case H2_ERR_STREAM_CLOSED : return "STREAM_CLOSED"; + case H2_ERR_FRAME_SIZE_ERROR : return "FRAME_SIZE_ERROR"; + case H2_ERR_REFUSED_STREAM : return "REFUSED_STREAM"; + case H2_ERR_CANCEL : return "CANCEL"; + case H2_ERR_COMPRESSION_ERROR : return "COMPRESSION_ERROR"; + case H2_ERR_CONNECT_ERROR : return "CONNECT_ERROR"; + case H2_ERR_ENHANCE_YOUR_CALM : return "ENHANCE_YOUR_CALM"; + case H2_ERR_INADEQUATE_SECURITY : return "INADEQUATE_SECURITY"; + case H2_ERR_HTTP_1_1_REQUIRED : return "HTTP_1_1_REQUIRED"; + default : return "_UNKNOWN_"; + } +} + /* Returns an error code if the frame is valid protocol-wise, otherwise 0. * is the frame type (H2_FT_*), is the direction (1=req, 2=res), is * the stream ID from the frame header, is the frame length from the