MEDIUM: h2: send connect protocol h2 settings

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.
This commit is contained in:
Amaury Denoyelle 2020-12-11 17:53:10 +01:00 committed by Christopher Faulet
parent c9a0afcc32
commit f9dcbeeab3
2 changed files with 15 additions and 6 deletions

View 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 */

View 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;
}
}