]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h1: report in the h1m struct if the HTTP version is 1.1 or above
authorWilly Tarreau <w@1wt.eu>
Thu, 13 Sep 2018 09:32:51 +0000 (11:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Sep 2018 12:34:09 +0000 (14:34 +0200)
This will be needed for the mux to know how to process the Connection
header, and will save it from having to re-parse the request line since
it's captured on the fly.

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

index 2dd58dd699925992a02c7298d9729194b1e2048d..dd883e87a30305e3f5ed423da2f0400f2503dffe 100644 (file)
@@ -140,6 +140,7 @@ enum h1m_state {
 #define H1_MF_CHNK              0x00000002 // chunk present, exclusive with c-l
 #define H1_MF_RESP              0x00000004 // this message is the response message
 #define H1_MF_TOLOWER           0x00000008 // turn the header names to lower case
+#define H1_MF_VER_11            0x00000010 // message indicates version 1.1 or above
 
 
 /* basic HTTP/1 message state for use in parsers. The err_pos field is special,
index 7a81c5099e327cebb09feed18373b2d97cf4fec3..ec8bb3870f850e989597cde0b694b88384faf110 100644 (file)
--- a/src/h1.c
+++ b/src/h1.c
@@ -896,6 +896,11 @@ int h1_headers_to_hdr_list(char *start, const char *stop,
                         */
 
                        if (likely(!skip_update)) {
+                               if ((sl.rq.v_l == 8) &&
+                                   ((start[sl.rq.v + 5] > '1') ||
+                                    ((start[sl.rq.v + 5] == '1') && (start[sl.rq.v + 7] >= '1'))))
+                                       h1m->flags |= H1_MF_VER_11;
+
                                if (unlikely(hdr_count >= hdr_num)) {
                                        state = H1_MSG_RQVER;
                                        goto http_output_full;
@@ -979,6 +984,12 @@ int h1_headers_to_hdr_list(char *start, const char *stop,
 
                if (likely(HTTP_IS_SPHT(*ptr))) {
                        sl.st.v_l = ptr - start;
+
+                       if ((sl.st.v_l == 8) &&
+                           ((start[sl.st.v + 5] > '1') ||
+                            ((start[sl.st.v + 5] == '1') && (start[sl.st.v + 7] >= '1'))))
+                               h1m->flags |= H1_MF_VER_11;
+
                        EAT_AND_JUMP_OR_RETURN(ptr, end, http_msg_rpver_sp, http_msg_ood, state, H1_MSG_RPVER_SP);
                }
                state = H1_MSG_RPVER;