Skip to content

Commit 95bdf37

Browse files
jasnelltargos
authored andcommitted
deps: update nghttp2 to 1.34.0
Key new feature: RFC 8441 `:protocol` support PR-URL: #23284 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 26c36ef commit 95bdf37

10 files changed

+96
-26
lines changed

deps/nghttp2/lib/includes/nghttp2/nghttp2.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,12 @@ typedef enum {
680680
/**
681681
* SETTINGS_MAX_HEADER_LIST_SIZE
682682
*/
683-
NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE = 0x06
683+
NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE = 0x06,
684+
/**
685+
* SETTINGS_ENABLE_CONNECT_PROTOCOL
686+
* (`RFC 8441 <https://tools.ietf.org/html/rfc8441>`_)
687+
*/
688+
NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL = 0x08
684689
} nghttp2_settings_id;
685690
/* Note: If we add SETTINGS, update the capacity of
686691
NGHTTP2_INBOUND_NUM_IV as well */

deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
* @macro
3030
* Version number of the nghttp2 library release
3131
*/
32-
#define NGHTTP2_VERSION "1.33.0"
32+
#define NGHTTP2_VERSION "1.34.0"
3333

3434
/**
3535
* @macro
3636
* Numerical representation of the version number of the nghttp2 library
3737
* release. This is a 24 bit number with 8 bits for major number, 8 bits
3838
* for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203.
3939
*/
40-
#define NGHTTP2_VERSION_NUM 0x012100
40+
#define NGHTTP2_VERSION_NUM 0x012200
4141

4242
#endif /* NGHTTP2VER_H */

deps/nghttp2/lib/nghttp2_frame.c

+5
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,11 @@ int nghttp2_iv_check(const nghttp2_settings_entry *iv, size_t niv) {
10501050
break;
10511051
case NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
10521052
break;
1053+
case NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
1054+
if (iv[i].value != 0 && iv[i].value != 1) {
1055+
return 0;
1056+
}
1057+
break;
10531058
}
10541059
}
10551060
return 1;

deps/nghttp2/lib/nghttp2_hd.c

+15-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
/* 3rd parameter is nghttp2_token value for header field name. We use
4646
first enum value if same header names are repeated (e.g.,
4747
:status). */
48-
static nghttp2_hd_static_entry static_table[] = {
48+
static const nghttp2_hd_static_entry static_table[] = {
4949
MAKE_STATIC_ENT(":authority", "", 0, 3153725150u),
5050
MAKE_STATIC_ENT(":method", "GET", 1, 695666056u),
5151
MAKE_STATIC_ENT(":method", "POST", 1, 695666056u),
@@ -271,6 +271,15 @@ static int32_t lookup_token(const uint8_t *name, size_t namelen) {
271271
break;
272272
}
273273
break;
274+
case 9:
275+
switch (name[8]) {
276+
case 'l':
277+
if (memeq(":protoco", name, 8)) {
278+
return NGHTTP2_TOKEN__PROTOCOL;
279+
}
280+
break;
281+
}
282+
break;
274283
case 10:
275284
switch (name[9]) {
276285
case 'e':
@@ -1159,7 +1168,7 @@ static search_result search_static_table(const nghttp2_nv *nv, int32_t token,
11591168
int name_only) {
11601169
search_result res = {token, 0};
11611170
int i;
1162-
nghttp2_hd_static_entry *ent;
1171+
const nghttp2_hd_static_entry *ent;
11631172

11641173
if (name_only) {
11651174
return res;
@@ -1184,7 +1193,7 @@ static search_result search_hd_table(nghttp2_hd_context *context,
11841193
int indexing_mode, nghttp2_hd_map *map,
11851194
uint32_t hash) {
11861195
search_result res = {-1, 0};
1187-
nghttp2_hd_entry *ent;
1196+
const nghttp2_hd_entry *ent;
11881197
int exact_match;
11891198
int name_only = indexing_mode == NGHTTP2_HD_NEVER_INDEXING;
11901199

@@ -1289,8 +1298,9 @@ nghttp2_hd_nv nghttp2_hd_table_get(nghttp2_hd_context *context, size_t idx) {
12891298
return hd_ringbuf_get(&context->hd_table, idx - NGHTTP2_STATIC_TABLE_LENGTH)
12901299
->nv;
12911300
} else {
1292-
nghttp2_hd_static_entry *ent = &static_table[idx];
1293-
nghttp2_hd_nv nv = {&ent->name, &ent->value, ent->token,
1301+
const nghttp2_hd_static_entry *ent = &static_table[idx];
1302+
nghttp2_hd_nv nv = {(nghttp2_rcbuf *)&ent->name,
1303+
(nghttp2_rcbuf *)&ent->value, ent->token,
12941304
NGHTTP2_NV_FLAG_NONE};
12951305
return nv;
12961306
}

deps/nghttp2/lib/nghttp2_hd.h

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ typedef enum {
111111
NGHTTP2_TOKEN_KEEP_ALIVE,
112112
NGHTTP2_TOKEN_PROXY_CONNECTION,
113113
NGHTTP2_TOKEN_UPGRADE,
114+
NGHTTP2_TOKEN__PROTOCOL,
114115
} nghttp2_token;
115116

116117
struct nghttp2_hd_entry;

deps/nghttp2/lib/nghttp2_helper.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ const char *nghttp2_strerror(int error_code) {
340340
}
341341

342342
/* Generated by gennmchartbl.py */
343-
static int VALID_HD_NAME_CHARS[] = {
343+
static const int VALID_HD_NAME_CHARS[] = {
344344
0 /* NUL */, 0 /* SOH */, 0 /* STX */, 0 /* ETX */,
345345
0 /* EOT */, 0 /* ENQ */, 0 /* ACK */, 0 /* BEL */,
346346
0 /* BS */, 0 /* HT */, 0 /* LF */, 0 /* VT */,
@@ -428,7 +428,7 @@ int nghttp2_check_header_name(const uint8_t *name, size_t len) {
428428
}
429429

430430
/* Generated by genvchartbl.py */
431-
static int VALID_HD_VALUE_CHARS[] = {
431+
static const int VALID_HD_VALUE_CHARS[] = {
432432
0 /* NUL */, 0 /* SOH */, 0 /* STX */, 0 /* ETX */,
433433
0 /* EOT */, 0 /* ENQ */, 0 /* ACK */, 0 /* BEL */,
434434
0 /* BS */, 1 /* HT */, 0 /* LF */, 0 /* VT */,

deps/nghttp2/lib/nghttp2_http.c

+24-15
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int check_path(nghttp2_stream *stream) {
113113
}
114114

115115
static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
116-
int trailer) {
116+
int trailer, int connect_protocol) {
117117
if (nv->name->base[0] == ':') {
118118
if (trailer ||
119119
(stream->http_flags & NGHTTP2_HTTP_FLAG_PSEUDO_HEADER_DISALLOWED)) {
@@ -146,10 +146,6 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
146146
return NGHTTP2_ERR_HTTP_HEADER;
147147
}
148148
stream->http_flags |= NGHTTP2_HTTP_FLAG_METH_CONNECT;
149-
if (stream->http_flags &
150-
(NGHTTP2_HTTP_FLAG__PATH | NGHTTP2_HTTP_FLAG__SCHEME)) {
151-
return NGHTTP2_ERR_HTTP_HEADER;
152-
}
153149
}
154150
break;
155151
case 'S':
@@ -162,9 +158,6 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
162158
}
163159
break;
164160
case NGHTTP2_TOKEN__PATH:
165-
if (stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT) {
166-
return NGHTTP2_ERR_HTTP_HEADER;
167-
}
168161
if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__PATH)) {
169162
return NGHTTP2_ERR_HTTP_HEADER;
170163
}
@@ -175,9 +168,6 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
175168
}
176169
break;
177170
case NGHTTP2_TOKEN__SCHEME:
178-
if (stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT) {
179-
return NGHTTP2_ERR_HTTP_HEADER;
180-
}
181171
if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__SCHEME)) {
182172
return NGHTTP2_ERR_HTTP_HEADER;
183173
}
@@ -186,6 +176,15 @@ static int http_request_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
186176
stream->http_flags |= NGHTTP2_HTTP_FLAG_SCHEME_HTTP;
187177
}
188178
break;
179+
case NGHTTP2_TOKEN__PROTOCOL:
180+
if (!connect_protocol) {
181+
return NGHTTP2_ERR_HTTP_HEADER;
182+
}
183+
184+
if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__PROTOCOL)) {
185+
return NGHTTP2_ERR_HTTP_HEADER;
186+
}
187+
break;
189188
case NGHTTP2_TOKEN_HOST:
190189
if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG_HOST)) {
191190
return NGHTTP2_ERR_HTTP_HEADER;
@@ -265,7 +264,7 @@ static int http_response_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
265264
return NGHTTP2_ERR_REMOVE_HTTP_HEADER;
266265
}
267266
if (stream->status_code / 100 == 1 ||
268-
(stream->status_code == 200 &&
267+
(stream->status_code / 100 == 2 &&
269268
(stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT))) {
270269
return NGHTTP2_ERR_HTTP_HEADER;
271270
}
@@ -458,16 +457,21 @@ int nghttp2_http_on_header(nghttp2_session *session, nghttp2_stream *stream,
458457
}
459458

460459
if (session->server || frame->hd.type == NGHTTP2_PUSH_PROMISE) {
461-
return http_request_on_header(stream, nv, trailer);
460+
return http_request_on_header(stream, nv, trailer,
461+
session->server &&
462+
session->pending_enable_connect_protocol);
462463
}
463464

464465
return http_response_on_header(stream, nv, trailer);
465466
}
466467

467468
int nghttp2_http_on_request_headers(nghttp2_stream *stream,
468469
nghttp2_frame *frame) {
469-
if (stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT) {
470-
if ((stream->http_flags & NGHTTP2_HTTP_FLAG__AUTHORITY) == 0) {
470+
if (!(stream->http_flags & NGHTTP2_HTTP_FLAG__PROTOCOL) &&
471+
(stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT)) {
472+
if ((stream->http_flags &
473+
(NGHTTP2_HTTP_FLAG__SCHEME | NGHTTP2_HTTP_FLAG__PATH)) ||
474+
(stream->http_flags & NGHTTP2_HTTP_FLAG__AUTHORITY) == 0) {
471475
return -1;
472476
}
473477
stream->content_length = -1;
@@ -478,6 +482,11 @@ int nghttp2_http_on_request_headers(nghttp2_stream *stream,
478482
(NGHTTP2_HTTP_FLAG__AUTHORITY | NGHTTP2_HTTP_FLAG_HOST)) == 0) {
479483
return -1;
480484
}
485+
if ((stream->http_flags & NGHTTP2_HTTP_FLAG__PROTOCOL) &&
486+
((stream->http_flags & NGHTTP2_HTTP_FLAG_METH_CONNECT) == 0 ||
487+
(stream->http_flags & NGHTTP2_HTTP_FLAG__AUTHORITY) == 0)) {
488+
return -1;
489+
}
481490
if (!check_path(stream)) {
482491
return -1;
483492
}

deps/nghttp2/lib/nghttp2_session.c

+35
Original file line numberDiff line numberDiff line change
@@ -4361,6 +4361,9 @@ int nghttp2_session_update_local_settings(nghttp2_session *session,
43614361
case NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
43624362
session->local_settings.max_header_list_size = iv[i].value;
43634363
break;
4364+
case NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
4365+
session->local_settings.enable_connect_protocol = iv[i].value;
4366+
break;
43644367
}
43654368
}
43664369

@@ -4499,6 +4502,26 @@ int nghttp2_session_on_settings_received(nghttp2_session *session,
44994502

45004503
session->remote_settings.max_header_list_size = entry->value;
45014504

4505+
break;
4506+
case NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
4507+
4508+
if (entry->value != 0 && entry->value != 1) {
4509+
return session_handle_invalid_connection(
4510+
session, frame, NGHTTP2_ERR_PROTO,
4511+
"SETTINGS: invalid SETTINGS_ENABLE_CONNECT_PROTOCOL");
4512+
}
4513+
4514+
if (!session->server &&
4515+
session->remote_settings.enable_connect_protocol &&
4516+
entry->value == 0) {
4517+
return session_handle_invalid_connection(
4518+
session, frame, NGHTTP2_ERR_PROTO,
4519+
"SETTINGS: server attempted to disable "
4520+
"SETTINGS_ENABLE_CONNECT_PROTOCOL");
4521+
}
4522+
4523+
session->remote_settings.enable_connect_protocol = entry->value;
4524+
45024525
break;
45034526
}
45044527
}
@@ -5250,6 +5273,7 @@ static void inbound_frame_set_settings_entry(nghttp2_inbound_frame *iframe) {
52505273
case NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE:
52515274
case NGHTTP2_SETTINGS_MAX_FRAME_SIZE:
52525275
case NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
5276+
case NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
52535277
break;
52545278
default:
52555279
DEBUGF("recv: unknown settings id=0x%02x\n", iv.settings_id);
@@ -7052,6 +7076,13 @@ int nghttp2_session_add_settings(nghttp2_session *session, uint8_t flags,
70527076
}
70537077
}
70547078

7079+
for (i = niv; i > 0; --i) {
7080+
if (iv[i - 1].settings_id == NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL) {
7081+
session->pending_enable_connect_protocol = (uint8_t)iv[i - 1].value;
7082+
break;
7083+
}
7084+
}
7085+
70557086
return 0;
70567087
}
70577088

@@ -7360,6 +7391,8 @@ uint32_t nghttp2_session_get_remote_settings(nghttp2_session *session,
73607391
return session->remote_settings.max_frame_size;
73617392
case NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
73627393
return session->remote_settings.max_header_list_size;
7394+
case NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
7395+
return session->remote_settings.enable_connect_protocol;
73637396
}
73647397

73657398
assert(0);
@@ -7381,6 +7414,8 @@ uint32_t nghttp2_session_get_local_settings(nghttp2_session *session,
73817414
return session->local_settings.max_frame_size;
73827415
case NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
73837416
return session->local_settings.max_header_list_size;
7417+
case NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
7418+
return session->local_settings.enable_connect_protocol;
73847419
}
73857420

73867421
assert(0);

deps/nghttp2/lib/nghttp2_session.h

+4
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ typedef struct {
164164
uint32_t initial_window_size;
165165
uint32_t max_frame_size;
166166
uint32_t max_header_list_size;
167+
uint32_t enable_connect_protocol;
167168
} nghttp2_settings_storage;
168169

169170
typedef enum {
@@ -321,6 +322,9 @@ struct nghttp2_session {
321322
/* Unacked local ENABLE_PUSH value. We use this to refuse
322323
PUSH_PROMISE before SETTINGS ACK is received. */
323324
uint8_t pending_enable_push;
325+
/* Unacked local ENABLE_CONNECT_PROTOCOL value. We use this to
326+
accept :protocol header field before SETTINGS_ACK is received. */
327+
uint8_t pending_enable_connect_protocol;
324328
/* Nonzero if the session is server side. */
325329
uint8_t server;
326330
/* Flags indicating GOAWAY is sent and/or received. The flags are

deps/nghttp2/lib/nghttp2_stream.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ typedef enum {
130130
/* "http" or "https" scheme */
131131
NGHTTP2_HTTP_FLAG_SCHEME_HTTP = 1 << 13,
132132
/* set if final response is expected */
133-
NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE = 1 << 14
133+
NGHTTP2_HTTP_FLAG_EXPECT_FINAL_RESPONSE = 1 << 14,
134+
NGHTTP2_HTTP_FLAG__PROTOCOL = 1 << 15,
134135
} nghttp2_http_flag;
135136

136137
struct nghttp2_stream {

0 commit comments

Comments
 (0)