]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h2: add a function to report H2 error codes as strings
authorWilly Tarreau <w@1wt.eu>
Sun, 24 Nov 2019 13:56:03 +0000 (14:56 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Nov 2019 10:34:26 +0000 (11:34 +0100)
Just like we have frame type to string, let's have error to string to
improve debugging and traces.

include/common/h2.h

index 1e0cf5ee8bc697ee7cc9f9bf4dea61bb3dea3058..03582992a4e57f79e28cc00a4b9ef59a10f597ee 100644 (file)
@@ -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. <ft>
  * is the frame type (H2_FT_*), <dir> is the direction (1=req, 2=res), <id> is
  * the stream ID from the frame header, <len> is the frame length from the