]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h1: Add the flag H1_MF_NO_PHDR to not add pseudo-headers during parsing
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 8 Oct 2018 13:50:15 +0000 (15:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 12 Oct 2018 14:15:18 +0000 (16:15 +0200)
Some pseudo-headers are added during the headers parsing, mainly for the mux
H2. With this flag, it is possible to not add them. This avoid some boring
filtering in the mux H1.

include/types/h1.h
src/h1.c

index af5c8962dde04df94e61aa86e5d7fed5ba4e5ef3..d3e44265307d807ab046961cbb63637c7a831bf1 100644 (file)
@@ -147,6 +147,7 @@ enum h1m_state {
 #define H1_MF_CONN_UPG          0x00000080 // message contains "connection: upgrade"
 #define H1_MF_XFER_LEN          0x00000100 // message xfer size can be determined
 #define H1_MF_XFER_ENC          0x00000200 // transfer-encoding is present
+#define H1_MF_NO_PHDR           0x00000400 // don't add pseudo-headers in the header list
 
 /* Note: for a connection to be persistent, we need this for the request :
  *   - one of CLEN or CHNK
index e3efd59594042aa48f127f05816a217b81bfe79c..c617372210925c9789b02be174646ec0211384a3 100644 (file)
--- a/src/h1.c
+++ b/src/h1.c
@@ -1053,13 +1053,15 @@ int h1_headers_to_hdr_list(char *start, const char *stop,
                                        state = H1_MSG_RQVER;
                                        goto http_output_full;
                                }
-                               http_set_hdr(&hdr[hdr_count++], ist(":method"), sl.rq.m);
+                               if (!(h1m->flags & H1_MF_NO_PHDR))
+                                       http_set_hdr(&hdr[hdr_count++], ist(":method"), sl.rq.m);
 
                                if (unlikely(hdr_count >= hdr_num)) {
                                        state = H1_MSG_RQVER;
                                        goto http_output_full;
                                }
-                               http_set_hdr(&hdr[hdr_count++], ist(":path"), sl.rq.u);
+                               if (!(h1m->flags & H1_MF_NO_PHDR))
+                                       http_set_hdr(&hdr[hdr_count++], ist(":path"), sl.rq.u);
                        }
 
                        sol = ptr - start;
@@ -1210,7 +1212,8 @@ int h1_headers_to_hdr_list(char *start, const char *stop,
                                state = H1_MSG_RPREASON;
                                goto http_output_full;
                        }
-                       http_set_hdr(&hdr[hdr_count++], ist(":status"), sl.st.c);
+                       if (!(h1m->flags & H1_MF_NO_PHDR))
+                               http_set_hdr(&hdr[hdr_count++], ist(":status"), sl.st.c);
                }
 
                sol = ptr - start;