MINOR: stream/mux: implement websocket stream flag
Define a new stream flag SF_WEBSOCKET and a new cs flag CS_FL_WEBSOCKET.
The conn-stream flag is first set by h1/h2 muxes if the request is a
valid websocket upgrade. The flag is then converted to SF_WEBSOCKET on
the stream creation.
This will be useful to properly manage websocket streams in
connect_server().
(cherry picked from commit 90ac605ef35d60323cfe4bc26cd56c2f97dc2277)
[ad: remove non present flag from context]
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 278636a..6bf5c14 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -1508,7 +1508,7 @@
* responsible of it. On error, <input> is unchanged, thus the mux must still
* take care of it.
*/
-static struct h2s *h2c_frt_stream_new(struct h2c *h2c, int id, struct buffer *input)
+static struct h2s *h2c_frt_stream_new(struct h2c *h2c, int id, struct buffer *input, uint32_t flags)
{
struct session *sess = h2c->conn->owner;
struct conn_stream *cs;
@@ -1532,6 +1532,12 @@
cs->ctx = h2s;
h2c->nb_cs++;
+ /* FIXME wrong analogy between ext-connect and websocket, this need to
+ * be refine.
+ */
+ if (flags & H2_SF_EXT_CONNECT_RCVD)
+ cs->flags |= CS_FL_WEBSOCKET;
+
if (stream_create_from_cs(cs, input) < 0)
goto out_free_cs;
@@ -2746,7 +2752,7 @@
* Xfer the rxbuf to the stream. On success, the new stream owns the
* rxbuf. On error, it is released here.
*/
- h2s = h2c_frt_stream_new(h2c, h2c->dsi, &rxbuf);
+ h2s = h2c_frt_stream_new(h2c, h2c->dsi, &rxbuf, flags);
if (!h2s) {
h2s = (struct h2s*)h2_refused_stream;
goto send_rst;