]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx/http-ana: Save info about Upgrade option in the Connection header
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 8 Jan 2021 14:53:01 +0000 (15:53 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 28 Jan 2021 15:27:48 +0000 (16:27 +0100)
Add an HTX start-line flag and its counterpart into the HTTP message to
track the presence of the Upgrade option into the Connection header. This
way, without parsing the Connection header again, it will be easy to know if
a client asks for a protocol upgrade and if the server agrees to do so. It
will also be easy to perform some conformance checks when a
101-switching-protocols is received.

include/haproxy/http_ana-t.h
include/haproxy/htx-t.h
src/h1_htx.c
src/http_ana.c

index 50fbd3de821916ec398263be600478ac0a7e9491..89d41dd7b3e4b7a31f9495aaba705c9a56da99fb 100644 (file)
@@ -89,6 +89,7 @@
 #define HTTP_MSGF_COMPRESSING 0x00000020  /* data compression is in progress */
 
 #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 */
 
 /* 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
index fb015752f5a8984ed3bfd81e0024a1925ecc9292..f14bb25e5e254cc75ed1735e0dd37a1e15e96ca4 100644 (file)
 #define HTX_SL_F_SCHM_HTTPS     0x00000200 /* The scheme HTTPS should be used */
 #define HTX_SL_F_HAS_AUTHORITY  0x00000400 /* The request authority is explicitly specified */
 #define HTX_SL_F_NORMALIZED_URI 0x00000800 /* The received URI is normalized (an implicit absolute-uri form) */
-
+#define HTX_SL_F_CONN_UPG       0x00001000 /* The message contains "connection: upgrade" header */
 
 /* HTX flags */
 #define HTX_FL_NONE              0x00000000
index 30e2b229e833a48100e8a1adfb599416f4a5eb14..dc6accabbddddca6a6cd89023c31df05639c7a38 100644 (file)
@@ -148,6 +148,8 @@ static unsigned int h1m_htx_sl_flags(struct h1m *h1m)
        }
        if (h1m->state == H1_MSG_TUNNEL)
                flags |= HTX_SL_F_BODYLESS;
+       if (h1m->flags & H1_MF_CONN_UPG)
+               flags |= HTX_SL_F_CONN_UPG;
        return flags;
 }
 
index 7816ad5630840fd5315eddbc48e6cb9510cd097d..96753c0ef6da27bedf97ac1546ec7b43d7789dc7 100644 (file)
@@ -166,6 +166,8 @@ int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
                msg->flags |= HTTP_MSGF_TE_CHNK;
        if (sl->flags & HTX_SL_F_BODYLESS)
                msg->flags |= HTTP_MSGF_BODYLESS;
+       if (sl->flags & HTX_SL_F_CONN_UPG)
+               msg->flags |= HTTP_MSGF_CONN_UPG;
 
        /* we can make use of server redirect on GET and HEAD */
        if (txn->meth == HTTP_METH_GET || txn->meth == HTTP_METH_HEAD)
@@ -1558,6 +1560,8 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
        }
        if (sl->flags & HTX_SL_F_BODYLESS)
                msg->flags |= HTTP_MSGF_BODYLESS;
+       if (sl->flags & HTX_SL_F_CONN_UPG)
+               msg->flags |= HTTP_MSGF_CONN_UPG;
 
        n = txn->status / 100;
        if (n < 1 || n > 5)