]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: flags/http_ana: use flag dumping to show http msg states
authorWilly Tarreau <w@1wt.eu>
Fri, 9 Sep 2022 15:18:57 +0000 (17:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Sep 2022 15:18:57 +0000 (17:18 +0200)
The function is hmsg_show_flags(). It shows the HTTP_MSGF_* flags.

dev/flags/flags.c
include/haproxy/http_ana-t.h

index 1afa9a9e2c4bd380c23b049eb1b070b95c2ace40..ac933e252a2ed79ab69a9edbab0b0075787dda3a 100644 (file)
 #define SHOW_AS_SD    0x00000100
 #define SHOW_AS_HSL   0x00000200
 #define SHOW_AS_HTX   0x00000400
+#define SHOW_AS_HMSG  0x00000800
 
 // command line names, must be in exact same order as the SHOW_AS_* flags above
 // so that show_as_words[i] matches flag 1U<<i.
-const char *show_as_words[] = { "ana", "chn", "conn", "sc", "stet", "strm", "task", "txn", "sd", "hsl", "htx", };
+const char *show_as_words[] = { "ana", "chn", "conn", "sc", "stet", "strm", "task", "txn", "sd", "hsl", "htx", "hmsg", };
 
 /* will be sufficient for even largest flag names */
 static char buf[4096];
@@ -129,6 +130,7 @@ int main(int argc, char **argv)
                if (show_as & SHOW_AS_TXN)   printf("txn->flags = %s\n",  (txn_show_flags    (buf, bsz, " | ", flags), buf));
                if (show_as & SHOW_AS_HSL)   printf("sl->flags = %s\n",   (hsl_show_flags    (buf, bsz, " | ", flags), buf));
                if (show_as & SHOW_AS_HTX)   printf("htx->flags = %s\n",  (htx_show_flags    (buf, bsz, " | ", flags), buf));
+               if (show_as & SHOW_AS_HMSG)  printf("hmsg->flags = %s\n", (hmsg_show_flags   (buf, bsz, " | ", flags), buf));
        }
        return 0;
 }
index 735a2fbaa44ed71baf8e291bce712ba41bcf0f8b..b9d65ec3b09c76c6b27891bc1db11428ace85b1f 100644 (file)
@@ -110,7 +110,8 @@ static forceinline char *txn_show_flags(char *buf, size_t len, const char *delim
 
 
 /*
- * HTTP message status flags (msg->flags)
+ * HTTP message status flags (msg->flags).
+ * Please also update the txn_show_flags() function below in case of changes.
  */
 #define HTTP_MSGF_CNT_LEN     0x00000001  /* content-length was found in the message */
 #define HTTP_MSGF_TE_CHNK     0x00000002  /* transfer-encoding: chunked was found */
@@ -129,6 +130,26 @@ static forceinline char *txn_show_flags(char *buf, size_t len, const char *delim
 #define HTTP_MSGF_BODYLESS    0x00000040  /* The message has no body (content-length = 0) */
 #define HTTP_MSGF_CONN_UPG    0x00000080  /* The message contains "Connection: Upgrade" header */
 
+/* This function is used to report flags in debugging tools. Please reflect
+ * below any single-bit flag addition above in the same order via the
+ * __APPEND_FLAG macro. The new end of the buffer is returned.
+ */
+static forceinline char *hmsg_show_flags(char *buf, size_t len, const char *delim, uint flg)
+{
+#define _(f, ...)     __APPEND_FLAG(buf, len, delim, flg, f, #f, __VA_ARGS__)
+       /* prologue */
+       _(0);
+       /* flags */
+       _(HTTP_MSGF_CNT_LEN, _(HTTP_MSGF_TE_CHNK, _(HTTP_MSGF_XFER_LEN,
+       _(HTTP_MSGF_VER_11, _(HTTP_MSGF_SOFT_RW, _(HTTP_MSGF_COMPRESSING,
+       _(HTTP_MSGF_BODYLESS, _(HTTP_MSGF_CONN_UPG))))))));
+       /* epilogue */
+       _(~0U);
+       return buf;
+#undef _
+}
+
+
 /* Maximum length of the cache secondary key (sum of all the possible parts of
  * the secondary key). The actual keys might be smaller for some
  * request/response pairs, because they depend on the responses' optional Vary