]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: h2: send connect protocol h2 settings
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 11 Dec 2020 16:53:10 +0000 (17:53 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 28 Jan 2021 15:37:14 +0000 (16:37 +0100)
In order to announce support for the Extended CONNECT h2 method by
haproxy, always send the ENABLE_CONNECT_PROTOCOL h2 settings. This new
setting has been described in the rfc 8441.

After receiving ENABLE_CONNECT_PROTOCOL, the client is free to use the
Extended CONNECT h2 method. This can notably be useful for the support
of websocket handshake on http/2.

include/haproxy/h2.h
src/mux_h2.c

index 34ad4de345924477ec9d2408aaafabeb5c210a62..1b49b850e27ecef64aa551a389ba0d85cb969551 100644 (file)
@@ -157,12 +157,13 @@ enum h2_err {
 } __attribute__((packed));
 
 // RFC7540 #11.3 : Settings Registry
-#define H2_SETTINGS_HEADER_TABLE_SIZE      0x0001
-#define H2_SETTINGS_ENABLE_PUSH            0x0002
-#define H2_SETTINGS_MAX_CONCURRENT_STREAMS 0x0003
-#define H2_SETTINGS_INITIAL_WINDOW_SIZE    0x0004
-#define H2_SETTINGS_MAX_FRAME_SIZE         0x0005
-#define H2_SETTINGS_MAX_HEADER_LIST_SIZE   0x0006
+#define H2_SETTINGS_HEADER_TABLE_SIZE       0x0001
+#define H2_SETTINGS_ENABLE_PUSH             0x0002
+#define H2_SETTINGS_MAX_CONCURRENT_STREAMS  0x0003
+#define H2_SETTINGS_INITIAL_WINDOW_SIZE     0x0004
+#define H2_SETTINGS_MAX_FRAME_SIZE          0x0005
+#define H2_SETTINGS_MAX_HEADER_LIST_SIZE    0x0006
+#define H2_SETTINGS_ENABLE_CONNECT_PROTOCOL 0x0008
 
 
 /* some protocol constants */
index 1fc6ca0b897f95abf685f5477f530bc8b7f34a75..b067f29786e716f854d086343e132e97f83516aa 100644 (file)
@@ -1593,6 +1593,10 @@ static int h2c_send_settings(struct h2c *h2c)
                chunk_memcat(&buf, "\x00\x02\x00\x00\x00\x00", 6);
        }
 
+       /* rfc 8441 #3 SETTINGS_ENABLE_CONNECT_PROTOCOL=1
+        * sent automatically */
+       chunk_memcat(&buf, "\x00\x08\x00\x00\x00\x01", 6);
+
        if (h2_settings_header_table_size != 4096) {
                char str[6] = "\x00\x01"; /* header_table_size */
 
@@ -2197,6 +2201,10 @@ static int h2c_handle_settings(struct h2c *h2c)
                                h2c->streams_limit = arg;
                        }
                        break;
+               case H2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
+                       /* nothing to do here as this settings is automatically
+                        * transmits to the client */
+                       break;
                }
        }