From: Willy Tarreau Date: Thu, 13 Sep 2018 09:32:51 +0000 (+0200) Subject: MINOR: h1: report in the h1m struct if the HTTP version is 1.1 or above X-Git-Tag: v1.9-dev3~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba5fbca33f3956df2c093ae46202c17f644cf81a;p=thirdparty%2Fhaproxy.git MINOR: h1: report in the h1m struct if the HTTP version is 1.1 or above 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. --- diff --git a/include/types/h1.h b/include/types/h1.h index 2dd58dd699..dd883e87a3 100644 --- a/include/types/h1.h +++ b/include/types/h1.h @@ -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, diff --git a/src/h1.c b/src/h1.c index 7a81c5099e..ec8bb3870f 100644 --- 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;