comparison src/http/v3/ngx_http_v3_module.c @ 9108:f742b1b46901 quic

HTTP/3: removed server push support.
author Roman Arutyunyan <arut@nginx.com>
date Fri, 12 May 2023 10:02:10 +0400
parents b9230e37b8a1
children ad3d34ddfdcc
comparison
equal deleted inserted replaced
9107:adcc6d8acfd4 9108:f742b1b46901
16 static void *ngx_http_v3_create_srv_conf(ngx_conf_t *cf); 16 static void *ngx_http_v3_create_srv_conf(ngx_conf_t *cf);
17 static char *ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, void *parent, 17 static char *ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, void *parent,
18 void *child); 18 void *child);
19 static char *ngx_http_quic_host_key(ngx_conf_t *cf, ngx_command_t *cmd, 19 static char *ngx_http_quic_host_key(ngx_conf_t *cf, ngx_command_t *cmd,
20 void *conf); 20 void *conf);
21 static void *ngx_http_v3_create_loc_conf(ngx_conf_t *cf);
22 static char *ngx_http_v3_merge_loc_conf(ngx_conf_t *cf, void *parent,
23 void *child);
24 static char *ngx_http_v3_push(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
25 21
26 22
27 static ngx_command_t ngx_http_v3_commands[] = { 23 static ngx_command_t ngx_http_v3_commands[] = {
28 24
29 { ngx_string("http3"), 25 { ngx_string("http3"),
38 ngx_conf_set_flag_slot, 34 ngx_conf_set_flag_slot,
39 NGX_HTTP_SRV_CONF_OFFSET, 35 NGX_HTTP_SRV_CONF_OFFSET,
40 offsetof(ngx_http_v3_srv_conf_t, enable_hq), 36 offsetof(ngx_http_v3_srv_conf_t, enable_hq),
41 NULL }, 37 NULL },
42 38
43 { ngx_string("http3_max_concurrent_pushes"),
44 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
45 ngx_conf_set_num_slot,
46 NGX_HTTP_SRV_CONF_OFFSET,
47 offsetof(ngx_http_v3_srv_conf_t, max_concurrent_pushes),
48 NULL },
49
50 { ngx_string("http3_max_concurrent_streams"), 39 { ngx_string("http3_max_concurrent_streams"),
51 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, 40 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
52 ngx_conf_set_num_slot, 41 ngx_conf_set_num_slot,
53 NGX_HTTP_SRV_CONF_OFFSET, 42 NGX_HTTP_SRV_CONF_OFFSET,
54 offsetof(ngx_http_v3_srv_conf_t, max_concurrent_streams), 43 offsetof(ngx_http_v3_srv_conf_t, max_concurrent_streams),
55 NULL }, 44 NULL },
56 45
57 { ngx_string("http3_push"),
58 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
59 ngx_http_v3_push,
60 NGX_HTTP_LOC_CONF_OFFSET,
61 0,
62 NULL },
63
64 { ngx_string("http3_push_preload"),
65 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
66 ngx_conf_set_flag_slot,
67 NGX_HTTP_LOC_CONF_OFFSET,
68 offsetof(ngx_http_v3_loc_conf_t, push_preload),
69 NULL },
70
71 { ngx_string("http3_stream_buffer_size"), 46 { ngx_string("http3_stream_buffer_size"),
72 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, 47 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
73 ngx_conf_set_size_slot, 48 ngx_conf_set_size_slot,
74 NGX_HTTP_SRV_CONF_OFFSET, 49 NGX_HTTP_SRV_CONF_OFFSET,
75 offsetof(ngx_http_v3_srv_conf_t, quic.stream_buffer_size), 50 offsetof(ngx_http_v3_srv_conf_t, quic.stream_buffer_size),
115 NULL, /* init main configuration */ 90 NULL, /* init main configuration */
116 91
117 ngx_http_v3_create_srv_conf, /* create server configuration */ 92 ngx_http_v3_create_srv_conf, /* create server configuration */
118 ngx_http_v3_merge_srv_conf, /* merge server configuration */ 93 ngx_http_v3_merge_srv_conf, /* merge server configuration */
119 94
120 ngx_http_v3_create_loc_conf, /* create location configuration */ 95 NULL, /* create location configuration */
121 ngx_http_v3_merge_loc_conf /* merge location configuration */ 96 NULL /* merge location configuration */
122 }; 97 };
123 98
124 99
125 ngx_module_t ngx_http_v3_module = { 100 ngx_module_t ngx_http_v3_module = {
126 NGX_MODULE_V1, 101 NGX_MODULE_V1,
222 */ 197 */
223 198
224 h3scf->enable = NGX_CONF_UNSET; 199 h3scf->enable = NGX_CONF_UNSET;
225 h3scf->enable_hq = NGX_CONF_UNSET; 200 h3scf->enable_hq = NGX_CONF_UNSET;
226 h3scf->max_table_capacity = NGX_HTTP_V3_MAX_TABLE_CAPACITY; 201 h3scf->max_table_capacity = NGX_HTTP_V3_MAX_TABLE_CAPACITY;
227 h3scf->max_concurrent_pushes = NGX_CONF_UNSET_UINT;
228 h3scf->max_concurrent_streams = NGX_CONF_UNSET_UINT; 202 h3scf->max_concurrent_streams = NGX_CONF_UNSET_UINT;
229 203
230 h3scf->quic.stream_buffer_size = NGX_CONF_UNSET_SIZE; 204 h3scf->quic.stream_buffer_size = NGX_CONF_UNSET_SIZE;
231 h3scf->quic.max_concurrent_streams_bidi = NGX_CONF_UNSET_UINT; 205 h3scf->quic.max_concurrent_streams_bidi = NGX_CONF_UNSET_UINT;
232 h3scf->quic.max_concurrent_streams_uni = NGX_HTTP_V3_MAX_UNI_STREAMS; 206 h3scf->quic.max_concurrent_streams_uni = NGX_HTTP_V3_MAX_UNI_STREAMS;
253 227
254 ngx_conf_merge_value(conf->enable, prev->enable, 1); 228 ngx_conf_merge_value(conf->enable, prev->enable, 1);
255 229
256 ngx_conf_merge_value(conf->enable_hq, prev->enable_hq, 0); 230 ngx_conf_merge_value(conf->enable_hq, prev->enable_hq, 0);
257 231
258 ngx_conf_merge_uint_value(conf->max_concurrent_pushes,
259 prev->max_concurrent_pushes, 10);
260
261 ngx_conf_merge_uint_value(conf->max_concurrent_streams, 232 ngx_conf_merge_uint_value(conf->max_concurrent_streams,
262 prev->max_concurrent_streams, 128); 233 prev->max_concurrent_streams, 128);
263 234
264 conf->max_blocked_streams = conf->max_concurrent_streams; 235 conf->max_blocked_streams = conf->max_concurrent_streams;
265 236
414 ngx_explicit_memzero(buf, size); 385 ngx_explicit_memzero(buf, size);
415 } 386 }
416 387
417 return NGX_CONF_ERROR; 388 return NGX_CONF_ERROR;
418 } 389 }
419
420
421 static void *
422 ngx_http_v3_create_loc_conf(ngx_conf_t *cf)
423 {
424 ngx_http_v3_loc_conf_t *h3lcf;
425
426 h3lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_v3_loc_conf_t));
427 if (h3lcf == NULL) {
428 return NULL;
429 }
430
431 /*
432 * set by ngx_pcalloc():
433 *
434 * h3lcf->pushes = NULL;
435 */
436
437 h3lcf->push_preload = NGX_CONF_UNSET;
438 h3lcf->push = NGX_CONF_UNSET;
439
440 return h3lcf;
441 }
442
443
444 static char *
445 ngx_http_v3_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
446 {
447 ngx_http_v3_loc_conf_t *prev = parent;
448 ngx_http_v3_loc_conf_t *conf = child;
449
450 ngx_conf_merge_value(conf->push, prev->push, 1);
451
452 if (conf->push && conf->pushes == NULL) {
453 conf->pushes = prev->pushes;
454 }
455
456 ngx_conf_merge_value(conf->push_preload, prev->push_preload, 0);
457
458 return NGX_CONF_OK;
459 }
460
461
462 static char *
463 ngx_http_v3_push(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
464 {
465 ngx_http_v3_loc_conf_t *h3lcf = conf;
466
467 ngx_str_t *value;
468 ngx_http_complex_value_t *cv;
469 ngx_http_compile_complex_value_t ccv;
470
471 value = cf->args->elts;
472
473 if (ngx_strcmp(value[1].data, "off") == 0) {
474
475 if (h3lcf->pushes) {
476 return "\"off\" parameter cannot be used with URI";
477 }
478
479 if (h3lcf->push == 0) {
480 return "is duplicate";
481 }
482
483 h3lcf->push = 0;
484 return NGX_CONF_OK;
485 }
486
487 if (h3lcf->push == 0) {
488 return "URI cannot be used with \"off\" parameter";
489 }
490
491 h3lcf->push = 1;
492
493 if (h3lcf->pushes == NULL) {
494 h3lcf->pushes = ngx_array_create(cf->pool, 1,
495 sizeof(ngx_http_complex_value_t));
496 if (h3lcf->pushes == NULL) {
497 return NGX_CONF_ERROR;
498 }
499 }
500
501 cv = ngx_array_push(h3lcf->pushes);
502 if (cv == NULL) {
503 return NGX_CONF_ERROR;
504 }
505
506 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
507
508 ccv.cf = cf;
509 ccv.value = &value[1];
510 ccv.complex_value = cv;
511
512 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
513 return NGX_CONF_ERROR;
514 }
515
516 return NGX_CONF_OK;
517 }