Skip to content

Commit 5afc77b

Browse files
jasnellBethGriggs
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 b095e35 commit 5afc77b

File tree

10 files changed

+96
-26
lines changed

10 files changed

+96
-26
lines changed

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

Lines changed: 6 additions & 1 deletion
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‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
* @macro
3030
* Version number of the nghttp2 library release
3131
*/
32-
#defineNGHTTP2_VERSION "1.33.0"
32+
#defineNGHTTP2_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-
#defineNGHTTP2_VERSION_NUM0x012100
40+
#defineNGHTTP2_VERSION_NUM0x012200
4141

4242
#endif/* NGHTTP2VER_H */

‎deps/nghttp2/lib/nghttp2_frame.c‎

Lines changed: 5 additions & 0 deletions
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
caseNGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
10521052
break;
1053+
caseNGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
1054+
if (iv[i].value!=0&&iv[i].value!=1){
1055+
return0;
1056+
}
1057+
break;
10531058
}
10541059
}
10551060
return1;

‎deps/nghttp2/lib/nghttp2_hd.c‎

Lines changed: 15 additions & 5 deletions
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-
staticnghttp2_hd_static_entrystatic_table[] ={
48+
staticconstnghttp2_hd_static_entrystatic_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+
case9:
275+
switch (name[8]){
276+
case'l':
277+
if (memeq(":protoco", name, 8)){
278+
returnNGHTTP2_TOKEN__PROTOCOL;
279+
}
280+
break;
281+
}
282+
break;
274283
case10:
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
intname_only){
11601169
search_resultres={token, 0};
11611170
inti;
1162-
nghttp2_hd_static_entry*ent;
1171+
constnghttp2_hd_static_entry*ent;
11631172

11641173
if (name_only){
11651174
returnres;
@@ -1184,7 +1193,7 @@ static search_result search_hd_table(nghttp2_hd_context *context,
11841193
intindexing_mode, nghttp2_hd_map*map,
11851194
uint32_thash){
11861195
search_resultres={-1, 0};
1187-
nghttp2_hd_entry*ent;
1196+
constnghttp2_hd_entry*ent;
11881197
intexact_match;
11891198
intname_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
returnhd_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_nvnv={&ent->name, &ent->value, ent->token,
1301+
constnghttp2_hd_static_entry*ent=&static_table[idx];
1302+
nghttp2_hd_nvnv={(nghttp2_rcbuf*)&ent->name,
1303+
(nghttp2_rcbuf*)&ent->value, ent->token,
12941304
NGHTTP2_NV_FLAG_NONE};
12951305
returnnv;
12961306
}

‎deps/nghttp2/lib/nghttp2_hd.h‎

Lines changed: 1 addition & 0 deletions
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
structnghttp2_hd_entry;

‎deps/nghttp2/lib/nghttp2_helper.c‎

Lines changed: 2 additions & 2 deletions
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-
staticintVALID_HD_NAME_CHARS[] ={
343+
staticconstintVALID_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-
staticintVALID_HD_VALUE_CHARS[] ={
431+
staticconstintVALID_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‎

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

115115
staticinthttp_request_on_header(nghttp2_stream*stream, nghttp2_hd_nv*nv,
116-
inttrailer){
116+
inttrailer, intconnect_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
returnNGHTTP2_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-
returnNGHTTP2_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
caseNGHTTP2_TOKEN__PATH:
165-
if (stream->http_flags&NGHTTP2_HTTP_FLAG_METH_CONNECT){
166-
returnNGHTTP2_ERR_HTTP_HEADER;
167-
}
168161
if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__PATH)){
169162
returnNGHTTP2_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
caseNGHTTP2_TOKEN__SCHEME:
178-
if (stream->http_flags&NGHTTP2_HTTP_FLAG_METH_CONNECT){
179-
returnNGHTTP2_ERR_HTTP_HEADER;
180-
}
181171
if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__SCHEME)){
182172
returnNGHTTP2_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+
caseNGHTTP2_TOKEN__PROTOCOL:
180+
if (!connect_protocol){
181+
returnNGHTTP2_ERR_HTTP_HEADER;
182+
}
183+
184+
if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG__PROTOCOL)){
185+
returnNGHTTP2_ERR_HTTP_HEADER;
186+
}
187+
break;
189188
caseNGHTTP2_TOKEN_HOST:
190189
if (!check_pseudo_header(stream, nv, NGHTTP2_HTTP_FLAG_HOST)){
191190
returnNGHTTP2_ERR_HTTP_HEADER;
@@ -265,7 +264,7 @@ static int http_response_on_header(nghttp2_stream *stream, nghttp2_hd_nv *nv,
265264
returnNGHTTP2_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
returnNGHTTP2_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-
returnhttp_request_on_header(stream, nv, trailer);
460+
returnhttp_request_on_header(stream, nv, trailer,
461+
session->server&&
462+
session->pending_enable_connect_protocol);
462463
}
463464

464465
returnhttp_response_on_header(stream, nv, trailer);
465466
}
466467

467468
intnghttp2_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‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4361,6 +4361,9 @@ int nghttp2_session_update_local_settings(nghttp2_session *session,
43614361
caseNGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
43624362
session->local_settings.max_header_list_size=iv[i].value;
43634363
break;
4364+
caseNGHTTP2_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+
caseNGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
4507+
4508+
if (entry->value!=0&&entry->value!=1){
4509+
returnsession_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+
returnsession_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
caseNGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE:
52515274
caseNGHTTP2_SETTINGS_MAX_FRAME_SIZE:
52525275
caseNGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
5276+
caseNGHTTP2_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
return0;
70567087
}
70577088

@@ -7360,6 +7391,8 @@ uint32_t nghttp2_session_get_remote_settings(nghttp2_session *session,
73607391
returnsession->remote_settings.max_frame_size;
73617392
caseNGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
73627393
returnsession->remote_settings.max_header_list_size;
7394+
caseNGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
7395+
returnsession->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
returnsession->local_settings.max_frame_size;
73827415
caseNGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
73837416
returnsession->local_settings.max_header_list_size;
7417+
caseNGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:
7418+
returnsession->local_settings.enable_connect_protocol;
73847419
}
73857420

73867421
assert(0);

‎deps/nghttp2/lib/nghttp2_session.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ typedef struct{
164164
uint32_tinitial_window_size;
165165
uint32_tmax_frame_size;
166166
uint32_tmax_header_list_size;
167+
uint32_tenable_connect_protocol;
167168
} nghttp2_settings_storage;
168169

169170
typedefenum{
@@ -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_tpending_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_tpending_enable_connect_protocol;
324328
/* Nonzero if the session is server side. */
325329
uint8_tserver;
326330
/* Flags indicating GOAWAY is sent and/or received. The flags are

‎deps/nghttp2/lib/nghttp2_stream.h‎

Lines changed: 2 additions & 1 deletion
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
structnghttp2_stream{

0 commit comments

Comments
(0)