]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h2: add a function to report pseudo-header names
authorWilly Tarreau <w@1wt.eu>
Sat, 30 Dec 2017 13:39:09 +0000 (14:39 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 30 Dec 2017 16:17:07 +0000 (17:17 +0100)
For debugging we need to be able to dump pseudo headers when we know
their name, let's put this there as we already have the other way
around.

include/common/h2.h

index 65c5ab1c8f411d1baf35bad3de3b8edef8417a76..fdeafe67d34506c7de530b469d89089ea98feb10 100644 (file)
@@ -190,6 +190,20 @@ static inline int h2_str_to_phdr(const struct ist str)
        return 0;
 }
 
+/* returns the pseudo-header name <num> as a string, or ":UNKNOWN" if unknown */
+static inline const char *h2_phdr_to_str(int phdr)
+{
+       switch (phdr) {
+       case H2_PHDR_IDX_NONE: return ":NONE";
+       case H2_PHDR_IDX_AUTH: return ":authority";
+       case H2_PHDR_IDX_METH: return ":method";
+       case H2_PHDR_IDX_PATH: return ":path";
+       case H2_PHDR_IDX_SCHM: return ":scheme";
+       case H2_PHDR_IDX_STAT: return ":status";
+       case H2_PHDR_IDX_HOST: return "Host";
+       default:               return ":UNKNOWN";
+       }
+}
 
 #endif /* _COMMON_H2_H */