Mercurial > hg > nginx-quic
comparison src/http/v3/ngx_http_v3_parse.c @ 8508:0ac25efb2da3 quic
HTTP/3: quic-qpack term updates.
Renamed header -> field per quic-qpack naming convention, in particular:
- Header Field -> Field Line
- Header Block -> (Encoded) Field Section
- Without Name Reference -> With Literal Name
- Header Acknowledgement -> Section Acknowledgment
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 01 Jul 2021 15:37:53 +0300 |
parents | 1fec68e322d0 |
children | d6e191a583cc |
comparison
equal
deleted
inserted
replaced
8507:f8ad3dd142ad | 8508:0ac25efb2da3 |
---|---|
17 static ngx_int_t ngx_http_v3_parse_varlen_int(ngx_connection_t *c, | 17 static ngx_int_t ngx_http_v3_parse_varlen_int(ngx_connection_t *c, |
18 ngx_http_v3_parse_varlen_int_t *st, u_char ch); | 18 ngx_http_v3_parse_varlen_int_t *st, u_char ch); |
19 static ngx_int_t ngx_http_v3_parse_prefix_int(ngx_connection_t *c, | 19 static ngx_int_t ngx_http_v3_parse_prefix_int(ngx_connection_t *c, |
20 ngx_http_v3_parse_prefix_int_t *st, ngx_uint_t prefix, u_char ch); | 20 ngx_http_v3_parse_prefix_int_t *st, ngx_uint_t prefix, u_char ch); |
21 | 21 |
22 static ngx_int_t ngx_http_v3_parse_header_block_prefix(ngx_connection_t *c, | 22 static ngx_int_t ngx_http_v3_parse_field_section_prefix(ngx_connection_t *c, |
23 ngx_http_v3_parse_header_block_prefix_t *st, u_char ch); | 23 ngx_http_v3_parse_field_section_prefix_t *st, u_char ch); |
24 static ngx_int_t ngx_http_v3_parse_header_rep(ngx_connection_t *c, | 24 static ngx_int_t ngx_http_v3_parse_field_rep(ngx_connection_t *c, |
25 ngx_http_v3_parse_header_rep_t *st, ngx_uint_t base, u_char ch); | 25 ngx_http_v3_parse_field_rep_t *st, ngx_uint_t base, u_char ch); |
26 static ngx_int_t ngx_http_v3_parse_literal(ngx_connection_t *c, | 26 static ngx_int_t ngx_http_v3_parse_literal(ngx_connection_t *c, |
27 ngx_http_v3_parse_literal_t *st, u_char ch); | 27 ngx_http_v3_parse_literal_t *st, u_char ch); |
28 static ngx_int_t ngx_http_v3_parse_header_ri(ngx_connection_t *c, | 28 static ngx_int_t ngx_http_v3_parse_field_ri(ngx_connection_t *c, |
29 ngx_http_v3_parse_header_t *st, u_char ch); | 29 ngx_http_v3_parse_field_t *st, u_char ch); |
30 static ngx_int_t ngx_http_v3_parse_header_lri(ngx_connection_t *c, | 30 static ngx_int_t ngx_http_v3_parse_field_lri(ngx_connection_t *c, |
31 ngx_http_v3_parse_header_t *st, u_char ch); | 31 ngx_http_v3_parse_field_t *st, u_char ch); |
32 static ngx_int_t ngx_http_v3_parse_header_l(ngx_connection_t *c, | 32 static ngx_int_t ngx_http_v3_parse_field_l(ngx_connection_t *c, |
33 ngx_http_v3_parse_header_t *st, u_char ch); | 33 ngx_http_v3_parse_field_t *st, u_char ch); |
34 static ngx_int_t ngx_http_v3_parse_header_pbi(ngx_connection_t *c, | 34 static ngx_int_t ngx_http_v3_parse_field_pbi(ngx_connection_t *c, |
35 ngx_http_v3_parse_header_t *st, u_char ch); | 35 ngx_http_v3_parse_field_t *st, u_char ch); |
36 static ngx_int_t ngx_http_v3_parse_header_lpbi(ngx_connection_t *c, | 36 static ngx_int_t ngx_http_v3_parse_field_lpbi(ngx_connection_t *c, |
37 ngx_http_v3_parse_header_t *st, u_char ch); | 37 ngx_http_v3_parse_field_t *st, u_char ch); |
38 | 38 |
39 static ngx_int_t ngx_http_v3_parse_control(ngx_connection_t *c, | 39 static ngx_int_t ngx_http_v3_parse_control(ngx_connection_t *c, |
40 ngx_http_v3_parse_control_t *st, u_char ch); | 40 ngx_http_v3_parse_control_t *st, u_char ch); |
41 static ngx_int_t ngx_http_v3_parse_settings(ngx_connection_t *c, | 41 static ngx_int_t ngx_http_v3_parse_settings(ngx_connection_t *c, |
42 ngx_http_v3_parse_settings_t *st, u_char ch); | 42 ngx_http_v3_parse_settings_t *st, u_char ch); |
43 | 43 |
44 static ngx_int_t ngx_http_v3_parse_encoder(ngx_connection_t *c, | 44 static ngx_int_t ngx_http_v3_parse_encoder(ngx_connection_t *c, |
45 ngx_http_v3_parse_encoder_t *st, u_char ch); | 45 ngx_http_v3_parse_encoder_t *st, u_char ch); |
46 static ngx_int_t ngx_http_v3_parse_header_inr(ngx_connection_t *c, | 46 static ngx_int_t ngx_http_v3_parse_field_inr(ngx_connection_t *c, |
47 ngx_http_v3_parse_header_t *st, u_char ch); | 47 ngx_http_v3_parse_field_t *st, u_char ch); |
48 static ngx_int_t ngx_http_v3_parse_header_iwnr(ngx_connection_t *c, | 48 static ngx_int_t ngx_http_v3_parse_field_iln(ngx_connection_t *c, |
49 ngx_http_v3_parse_header_t *st, u_char ch); | 49 ngx_http_v3_parse_field_t *st, u_char ch); |
50 | 50 |
51 static ngx_int_t ngx_http_v3_parse_decoder(ngx_connection_t *c, | 51 static ngx_int_t ngx_http_v3_parse_decoder(ngx_connection_t *c, |
52 ngx_http_v3_parse_decoder_t *st, u_char ch); | 52 ngx_http_v3_parse_decoder_t *st, u_char ch); |
53 | 53 |
54 static ngx_int_t ngx_http_v3_parse_lookup(ngx_connection_t *c, | 54 static ngx_int_t ngx_http_v3_parse_lookup(ngx_connection_t *c, |
199 sw_type, | 199 sw_type, |
200 sw_length, | 200 sw_length, |
201 sw_skip, | 201 sw_skip, |
202 sw_prefix, | 202 sw_prefix, |
203 sw_verify, | 203 sw_verify, |
204 sw_header_rep, | 204 sw_field_rep, |
205 sw_done | 205 sw_done |
206 }; | 206 }; |
207 | 207 |
208 switch (st->state) { | 208 switch (st->state) { |
209 | 209 |
275 | 275 |
276 if (--st->length == 0) { | 276 if (--st->length == 0) { |
277 return NGX_HTTP_V3_ERR_FRAME_ERROR; | 277 return NGX_HTTP_V3_ERR_FRAME_ERROR; |
278 } | 278 } |
279 | 279 |
280 rc = ngx_http_v3_parse_header_block_prefix(c, &st->prefix, ch); | 280 rc = ngx_http_v3_parse_field_section_prefix(c, &st->prefix, ch); |
281 if (rc != NGX_DONE) { | 281 if (rc != NGX_DONE) { |
282 return rc; | 282 return rc; |
283 } | 283 } |
284 | 284 |
285 st->state = sw_verify; | 285 st->state = sw_verify; |
290 rc = ngx_http_v3_check_insert_count(c, st->prefix.insert_count); | 290 rc = ngx_http_v3_check_insert_count(c, st->prefix.insert_count); |
291 if (rc != NGX_OK) { | 291 if (rc != NGX_OK) { |
292 return rc; | 292 return rc; |
293 } | 293 } |
294 | 294 |
295 st->state = sw_header_rep; | 295 st->state = sw_field_rep; |
296 | 296 |
297 /* fall through */ | 297 /* fall through */ |
298 | 298 |
299 case sw_header_rep: | 299 case sw_field_rep: |
300 | 300 |
301 rc = ngx_http_v3_parse_header_rep(c, &st->header_rep, st->prefix.base, | 301 rc = ngx_http_v3_parse_field_rep(c, &st->field_rep, st->prefix.base, |
302 ch); | 302 ch); |
303 | 303 |
304 if (--st->length == 0 && rc == NGX_AGAIN) { | 304 if (--st->length == 0 && rc == NGX_AGAIN) { |
305 return NGX_HTTP_V3_ERR_FRAME_ERROR; | 305 return NGX_HTTP_V3_ERR_FRAME_ERROR; |
306 } | 306 } |
307 | 307 |
321 done: | 321 done: |
322 | 322 |
323 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse headers done"); | 323 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse headers done"); |
324 | 324 |
325 if (st->prefix.insert_count > 0) { | 325 if (st->prefix.insert_count > 0) { |
326 if (ngx_http_v3_send_ack_header(c, c->quic->id) != NGX_OK) { | 326 if (ngx_http_v3_send_ack_section(c, c->quic->id) != NGX_OK) { |
327 return NGX_ERROR; | 327 return NGX_ERROR; |
328 } | 328 } |
329 } | 329 } |
330 | 330 |
331 st->state = sw_start; | 331 st->state = sw_start; |
332 return NGX_DONE; | 332 return NGX_DONE; |
333 } | 333 } |
334 | 334 |
335 | 335 |
336 static ngx_int_t | 336 static ngx_int_t |
337 ngx_http_v3_parse_header_block_prefix(ngx_connection_t *c, | 337 ngx_http_v3_parse_field_section_prefix(ngx_connection_t *c, |
338 ngx_http_v3_parse_header_block_prefix_t *st, u_char ch) | 338 ngx_http_v3_parse_field_section_prefix_t *st, u_char ch) |
339 { | 339 { |
340 ngx_int_t rc; | 340 ngx_int_t rc; |
341 enum { | 341 enum { |
342 sw_start = 0, | 342 sw_start = 0, |
343 sw_req_insert_count, | 343 sw_req_insert_count, |
348 switch (st->state) { | 348 switch (st->state) { |
349 | 349 |
350 case sw_start: | 350 case sw_start: |
351 | 351 |
352 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, | 352 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
353 "http3 parse header block prefix"); | 353 "http3 parse field section prefix"); |
354 | 354 |
355 st->state = sw_req_insert_count; | 355 st->state = sw_req_insert_count; |
356 | 356 |
357 /* fall through */ | 357 /* fall through */ |
358 | 358 |
399 } else { | 399 } else { |
400 st->base = st->insert_count + st->delta_base; | 400 st->base = st->insert_count + st->delta_base; |
401 } | 401 } |
402 | 402 |
403 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, c->log, 0, | 403 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, c->log, 0, |
404 "http3 parse header block prefix done " | 404 "http3 parse field section prefix done " |
405 "insert_count:%ui, sign:%ui, delta_base:%ui, base:%ui", | 405 "insert_count:%ui, sign:%ui, delta_base:%ui, base:%ui", |
406 st->insert_count, st->sign, st->delta_base, st->base); | 406 st->insert_count, st->sign, st->delta_base, st->base); |
407 | 407 |
408 st->state = sw_start; | 408 st->state = sw_start; |
409 return NGX_DONE; | 409 return NGX_DONE; |
410 } | 410 } |
411 | 411 |
412 | 412 |
413 static ngx_int_t | 413 static ngx_int_t |
414 ngx_http_v3_parse_header_rep(ngx_connection_t *c, | 414 ngx_http_v3_parse_field_rep(ngx_connection_t *c, |
415 ngx_http_v3_parse_header_rep_t *st, ngx_uint_t base, u_char ch) | 415 ngx_http_v3_parse_field_rep_t *st, ngx_uint_t base, u_char ch) |
416 { | 416 { |
417 ngx_int_t rc; | 417 ngx_int_t rc; |
418 enum { | 418 enum { |
419 sw_start = 0, | 419 sw_start = 0, |
420 sw_header_ri, | 420 sw_field_ri, |
421 sw_header_lri, | 421 sw_field_lri, |
422 sw_header_l, | 422 sw_field_l, |
423 sw_header_pbi, | 423 sw_field_pbi, |
424 sw_header_lpbi | 424 sw_field_lpbi |
425 }; | 425 }; |
426 | 426 |
427 if (st->state == sw_start) { | 427 if (st->state == sw_start) { |
428 | 428 |
429 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, | 429 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
430 "http3 parse header representation"); | 430 "http3 parse field representation"); |
431 | 431 |
432 ngx_memzero(&st->header, sizeof(ngx_http_v3_parse_header_t)); | 432 ngx_memzero(&st->field, sizeof(ngx_http_v3_parse_field_t)); |
433 | 433 |
434 st->header.base = base; | 434 st->field.base = base; |
435 | 435 |
436 if (ch & 0x80) { | 436 if (ch & 0x80) { |
437 /* Indexed Header Field */ | 437 /* Indexed Field Line */ |
438 | 438 |
439 st->state = sw_header_ri; | 439 st->state = sw_field_ri; |
440 | 440 |
441 } else if (ch & 0x40) { | 441 } else if (ch & 0x40) { |
442 /* Literal Header Field With Name Reference */ | 442 /* Literal Field Line With Name Reference */ |
443 | 443 |
444 st->state = sw_header_lri; | 444 st->state = sw_field_lri; |
445 | 445 |
446 } else if (ch & 0x20) { | 446 } else if (ch & 0x20) { |
447 /* Literal Header Field Without Name Reference */ | 447 /* Literal Field Line With Literal Name */ |
448 | 448 |
449 st->state = sw_header_l; | 449 st->state = sw_field_l; |
450 | 450 |
451 } else if (ch & 0x10) { | 451 } else if (ch & 0x10) { |
452 /* Indexed Header Field With Post-Base Index */ | 452 /* Indexed Field Line With Post-Base Index */ |
453 | 453 |
454 st->state = sw_header_pbi; | 454 st->state = sw_field_pbi; |
455 | 455 |
456 } else { | 456 } else { |
457 /* Literal Header Field With Post-Base Name Reference */ | 457 /* Literal Field Line With Post-Base Name Reference */ |
458 | 458 |
459 st->state = sw_header_lpbi; | 459 st->state = sw_field_lpbi; |
460 } | 460 } |
461 } | 461 } |
462 | 462 |
463 switch (st->state) { | 463 switch (st->state) { |
464 | 464 |
465 case sw_header_ri: | 465 case sw_field_ri: |
466 rc = ngx_http_v3_parse_header_ri(c, &st->header, ch); | 466 rc = ngx_http_v3_parse_field_ri(c, &st->field, ch); |
467 break; | 467 break; |
468 | 468 |
469 case sw_header_lri: | 469 case sw_field_lri: |
470 rc = ngx_http_v3_parse_header_lri(c, &st->header, ch); | 470 rc = ngx_http_v3_parse_field_lri(c, &st->field, ch); |
471 break; | 471 break; |
472 | 472 |
473 case sw_header_l: | 473 case sw_field_l: |
474 rc = ngx_http_v3_parse_header_l(c, &st->header, ch); | 474 rc = ngx_http_v3_parse_field_l(c, &st->field, ch); |
475 break; | 475 break; |
476 | 476 |
477 case sw_header_pbi: | 477 case sw_field_pbi: |
478 rc = ngx_http_v3_parse_header_pbi(c, &st->header, ch); | 478 rc = ngx_http_v3_parse_field_pbi(c, &st->field, ch); |
479 break; | 479 break; |
480 | 480 |
481 case sw_header_lpbi: | 481 case sw_field_lpbi: |
482 rc = ngx_http_v3_parse_header_lpbi(c, &st->header, ch); | 482 rc = ngx_http_v3_parse_field_lpbi(c, &st->field, ch); |
483 break; | 483 break; |
484 | 484 |
485 default: | 485 default: |
486 rc = NGX_OK; | 486 rc = NGX_OK; |
487 } | 487 } |
489 if (rc != NGX_DONE) { | 489 if (rc != NGX_DONE) { |
490 return rc; | 490 return rc; |
491 } | 491 } |
492 | 492 |
493 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, | 493 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
494 "http3 parse header representation done"); | 494 "http3 parse field representation done"); |
495 | 495 |
496 st->state = sw_start; | 496 st->state = sw_start; |
497 return NGX_DONE; | 497 return NGX_DONE; |
498 } | 498 } |
499 | 499 |
521 | 521 |
522 cscf = ngx_http_v3_get_module_srv_conf(c, ngx_http_core_module); | 522 cscf = ngx_http_v3_get_module_srv_conf(c, ngx_http_core_module); |
523 | 523 |
524 if (n > cscf->large_client_header_buffers.size) { | 524 if (n > cscf->large_client_header_buffers.size) { |
525 ngx_log_error(NGX_LOG_INFO, c->log, 0, | 525 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
526 "client sent too large header field"); | 526 "client sent too large field line"); |
527 return NGX_HTTP_V3_ERR_EXCESSIVE_LOAD; | 527 return NGX_HTTP_V3_ERR_EXCESSIVE_LOAD; |
528 } | 528 } |
529 | 529 |
530 if (st->huffman) { | 530 if (st->huffman) { |
531 n = n * 8 / 5; | 531 n = n * 8 / 5; |
576 return NGX_DONE; | 576 return NGX_DONE; |
577 } | 577 } |
578 | 578 |
579 | 579 |
580 static ngx_int_t | 580 static ngx_int_t |
581 ngx_http_v3_parse_header_ri(ngx_connection_t *c, ngx_http_v3_parse_header_t *st, | 581 ngx_http_v3_parse_field_ri(ngx_connection_t *c, ngx_http_v3_parse_field_t *st, |
582 u_char ch) | 582 u_char ch) |
583 { | 583 { |
584 ngx_int_t rc; | 584 ngx_int_t rc; |
585 enum { | 585 enum { |
586 sw_start = 0, | 586 sw_start = 0, |
589 | 589 |
590 switch (st->state) { | 590 switch (st->state) { |
591 | 591 |
592 case sw_start: | 592 case sw_start: |
593 | 593 |
594 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse header ri"); | 594 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse field ri"); |
595 | 595 |
596 st->dynamic = (ch & 0x40) ? 0 : 1; | 596 st->dynamic = (ch & 0x40) ? 0 : 1; |
597 st->state = sw_index; | 597 st->state = sw_index; |
598 | 598 |
599 /* fall through */ | 599 /* fall through */ |
612 return NGX_AGAIN; | 612 return NGX_AGAIN; |
613 | 613 |
614 done: | 614 done: |
615 | 615 |
616 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | 616 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
617 "http3 parse header ri done %s%ui]", | 617 "http3 parse field ri done %s%ui]", |
618 st->dynamic ? "dynamic[-" : "static[", st->index); | 618 st->dynamic ? "dynamic[-" : "static[", st->index); |
619 | 619 |
620 if (st->dynamic) { | 620 if (st->dynamic) { |
621 st->index = st->base - st->index - 1; | 621 st->index = st->base - st->index - 1; |
622 } | 622 } |
631 return NGX_DONE; | 631 return NGX_DONE; |
632 } | 632 } |
633 | 633 |
634 | 634 |
635 static ngx_int_t | 635 static ngx_int_t |
636 ngx_http_v3_parse_header_lri(ngx_connection_t *c, | 636 ngx_http_v3_parse_field_lri(ngx_connection_t *c, |
637 ngx_http_v3_parse_header_t *st, u_char ch) | 637 ngx_http_v3_parse_field_t *st, u_char ch) |
638 { | 638 { |
639 ngx_int_t rc; | 639 ngx_int_t rc; |
640 enum { | 640 enum { |
641 sw_start = 0, | 641 sw_start = 0, |
642 sw_index, | 642 sw_index, |
647 | 647 |
648 switch (st->state) { | 648 switch (st->state) { |
649 | 649 |
650 case sw_start: | 650 case sw_start: |
651 | 651 |
652 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse header lri"); | 652 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse field lri"); |
653 | 653 |
654 st->dynamic = (ch & 0x10) ? 0 : 1; | 654 st->dynamic = (ch & 0x10) ? 0 : 1; |
655 st->state = sw_index; | 655 st->state = sw_index; |
656 | 656 |
657 /* fall through */ | 657 /* fall through */ |
703 return NGX_AGAIN; | 703 return NGX_AGAIN; |
704 | 704 |
705 done: | 705 done: |
706 | 706 |
707 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, | 707 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, |
708 "http3 parse header lri done %s%ui] \"%V\"", | 708 "http3 parse field lri done %s%ui] \"%V\"", |
709 st->dynamic ? "dynamic[-" : "static[", | 709 st->dynamic ? "dynamic[-" : "static[", |
710 st->index, &st->value); | 710 st->index, &st->value); |
711 | 711 |
712 if (st->dynamic) { | 712 if (st->dynamic) { |
713 st->index = st->base - st->index - 1; | 713 st->index = st->base - st->index - 1; |
722 return NGX_DONE; | 722 return NGX_DONE; |
723 } | 723 } |
724 | 724 |
725 | 725 |
726 static ngx_int_t | 726 static ngx_int_t |
727 ngx_http_v3_parse_header_l(ngx_connection_t *c, | 727 ngx_http_v3_parse_field_l(ngx_connection_t *c, |
728 ngx_http_v3_parse_header_t *st, u_char ch) | 728 ngx_http_v3_parse_field_t *st, u_char ch) |
729 { | 729 { |
730 ngx_int_t rc; | 730 ngx_int_t rc; |
731 enum { | 731 enum { |
732 sw_start = 0, | 732 sw_start = 0, |
733 sw_name_len, | 733 sw_name_len, |
739 | 739 |
740 switch (st->state) { | 740 switch (st->state) { |
741 | 741 |
742 case sw_start: | 742 case sw_start: |
743 | 743 |
744 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse header l"); | 744 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse field l"); |
745 | 745 |
746 st->literal.huffman = (ch & 0x08) ? 1 : 0; | 746 st->literal.huffman = (ch & 0x08) ? 1 : 0; |
747 st->state = sw_name_len; | 747 st->state = sw_name_len; |
748 | 748 |
749 /* fall through */ | 749 /* fall through */ |
810 return NGX_AGAIN; | 810 return NGX_AGAIN; |
811 | 811 |
812 done: | 812 done: |
813 | 813 |
814 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | 814 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
815 "http3 parse header l done \"%V\" \"%V\"", | 815 "http3 parse field l done \"%V\" \"%V\"", |
816 &st->name, &st->value); | 816 &st->name, &st->value); |
817 | 817 |
818 st->state = sw_start; | 818 st->state = sw_start; |
819 return NGX_DONE; | 819 return NGX_DONE; |
820 } | 820 } |
821 | 821 |
822 | 822 |
823 static ngx_int_t | 823 static ngx_int_t |
824 ngx_http_v3_parse_header_pbi(ngx_connection_t *c, | 824 ngx_http_v3_parse_field_pbi(ngx_connection_t *c, |
825 ngx_http_v3_parse_header_t *st, u_char ch) | 825 ngx_http_v3_parse_field_t *st, u_char ch) |
826 { | 826 { |
827 ngx_int_t rc; | 827 ngx_int_t rc; |
828 enum { | 828 enum { |
829 sw_start = 0, | 829 sw_start = 0, |
830 sw_index | 830 sw_index |
832 | 832 |
833 switch (st->state) { | 833 switch (st->state) { |
834 | 834 |
835 case sw_start: | 835 case sw_start: |
836 | 836 |
837 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse header pbi"); | 837 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse field pbi"); |
838 | 838 |
839 st->state = sw_index; | 839 st->state = sw_index; |
840 | 840 |
841 /* fall through */ | 841 /* fall through */ |
842 | 842 |
854 return NGX_AGAIN; | 854 return NGX_AGAIN; |
855 | 855 |
856 done: | 856 done: |
857 | 857 |
858 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | 858 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
859 "http3 parse header pbi done dynamic[+%ui]", st->index); | 859 "http3 parse field pbi done dynamic[+%ui]", st->index); |
860 | 860 |
861 rc = ngx_http_v3_parse_lookup(c, 1, st->base + st->index, &st->name, | 861 rc = ngx_http_v3_parse_lookup(c, 1, st->base + st->index, &st->name, |
862 &st->value); | 862 &st->value); |
863 if (rc != NGX_OK) { | 863 if (rc != NGX_OK) { |
864 return rc; | 864 return rc; |
868 return NGX_DONE; | 868 return NGX_DONE; |
869 } | 869 } |
870 | 870 |
871 | 871 |
872 static ngx_int_t | 872 static ngx_int_t |
873 ngx_http_v3_parse_header_lpbi(ngx_connection_t *c, | 873 ngx_http_v3_parse_field_lpbi(ngx_connection_t *c, |
874 ngx_http_v3_parse_header_t *st, u_char ch) | 874 ngx_http_v3_parse_field_t *st, u_char ch) |
875 { | 875 { |
876 ngx_int_t rc; | 876 ngx_int_t rc; |
877 enum { | 877 enum { |
878 sw_start = 0, | 878 sw_start = 0, |
879 sw_index, | 879 sw_index, |
885 switch (st->state) { | 885 switch (st->state) { |
886 | 886 |
887 case sw_start: | 887 case sw_start: |
888 | 888 |
889 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, | 889 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
890 "http3 parse header lpbi"); | 890 "http3 parse field lpbi"); |
891 | 891 |
892 st->state = sw_index; | 892 st->state = sw_index; |
893 | 893 |
894 /* fall through */ | 894 /* fall through */ |
895 | 895 |
940 return NGX_AGAIN; | 940 return NGX_AGAIN; |
941 | 941 |
942 done: | 942 done: |
943 | 943 |
944 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | 944 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
945 "http3 parse header lpbi done dynamic[+%ui] \"%V\"", | 945 "http3 parse field lpbi done dynamic[+%ui] \"%V\"", |
946 st->index, &st->value); | 946 st->index, &st->value); |
947 | 947 |
948 rc = ngx_http_v3_parse_lookup(c, 1, st->base + st->index, &st->name, NULL); | 948 rc = ngx_http_v3_parse_lookup(c, 1, st->base + st->index, &st->name, NULL); |
949 if (rc != NGX_OK) { | 949 if (rc != NGX_OK) { |
950 return rc; | 950 return rc; |
1258 { | 1258 { |
1259 ngx_int_t rc; | 1259 ngx_int_t rc; |
1260 enum { | 1260 enum { |
1261 sw_start = 0, | 1261 sw_start = 0, |
1262 sw_inr, | 1262 sw_inr, |
1263 sw_iwnr, | 1263 sw_iln, |
1264 sw_capacity, | 1264 sw_capacity, |
1265 sw_duplicate | 1265 sw_duplicate |
1266 }; | 1266 }; |
1267 | 1267 |
1268 if (st->state == sw_start) { | 1268 if (st->state == sw_start) { |
1274 /* Insert With Name Reference */ | 1274 /* Insert With Name Reference */ |
1275 | 1275 |
1276 st->state = sw_inr; | 1276 st->state = sw_inr; |
1277 | 1277 |
1278 } else if (ch & 0x40) { | 1278 } else if (ch & 0x40) { |
1279 /* Insert Without Name Reference */ | 1279 /* Insert With Literal Name */ |
1280 | 1280 |
1281 st->state = sw_iwnr; | 1281 st->state = sw_iln; |
1282 | 1282 |
1283 } else if (ch & 0x20) { | 1283 } else if (ch & 0x20) { |
1284 /* Set Dynamic Table Capacity */ | 1284 /* Set Dynamic Table Capacity */ |
1285 | 1285 |
1286 st->state = sw_capacity; | 1286 st->state = sw_capacity; |
1287 | 1287 |
1288 } else { | 1288 } else { |
1289 /* Duplicate */ | 1289 /* Duplicate */ |
1294 | 1294 |
1295 switch (st->state) { | 1295 switch (st->state) { |
1296 | 1296 |
1297 case sw_inr: | 1297 case sw_inr: |
1298 | 1298 |
1299 rc = ngx_http_v3_parse_header_inr(c, &st->header, ch); | 1299 rc = ngx_http_v3_parse_field_inr(c, &st->field, ch); |
1300 if (rc != NGX_DONE) { | 1300 if (rc != NGX_DONE) { |
1301 return rc; | 1301 return rc; |
1302 } | 1302 } |
1303 | 1303 |
1304 goto done; | 1304 goto done; |
1305 | 1305 |
1306 case sw_iwnr: | 1306 case sw_iln: |
1307 | 1307 |
1308 rc = ngx_http_v3_parse_header_iwnr(c, &st->header, ch); | 1308 rc = ngx_http_v3_parse_field_iln(c, &st->field, ch); |
1309 if (rc != NGX_DONE) { | 1309 if (rc != NGX_DONE) { |
1310 return rc; | 1310 return rc; |
1311 } | 1311 } |
1312 | 1312 |
1313 goto done; | 1313 goto done; |
1352 return NGX_AGAIN; | 1352 return NGX_AGAIN; |
1353 } | 1353 } |
1354 | 1354 |
1355 | 1355 |
1356 static ngx_int_t | 1356 static ngx_int_t |
1357 ngx_http_v3_parse_header_inr(ngx_connection_t *c, | 1357 ngx_http_v3_parse_field_inr(ngx_connection_t *c, |
1358 ngx_http_v3_parse_header_t *st, u_char ch) | 1358 ngx_http_v3_parse_field_t *st, u_char ch) |
1359 { | 1359 { |
1360 ngx_int_t rc; | 1360 ngx_int_t rc; |
1361 enum { | 1361 enum { |
1362 sw_start = 0, | 1362 sw_start = 0, |
1363 sw_name_index, | 1363 sw_name_index, |
1368 | 1368 |
1369 switch (st->state) { | 1369 switch (st->state) { |
1370 | 1370 |
1371 case sw_start: | 1371 case sw_start: |
1372 | 1372 |
1373 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse header inr"); | 1373 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse field inr"); |
1374 | 1374 |
1375 st->dynamic = (ch & 0x40) ? 0 : 1; | 1375 st->dynamic = (ch & 0x40) ? 0 : 1; |
1376 st->state = sw_name_index; | 1376 st->state = sw_name_index; |
1377 | 1377 |
1378 /* fall through */ | 1378 /* fall through */ |
1425 return NGX_AGAIN; | 1425 return NGX_AGAIN; |
1426 | 1426 |
1427 done: | 1427 done: |
1428 | 1428 |
1429 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, | 1429 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, |
1430 "http3 parse header inr done %s[%ui] \"%V\"", | 1430 "http3 parse field inr done %s[%ui] \"%V\"", |
1431 st->dynamic ? "dynamic" : "static", | 1431 st->dynamic ? "dynamic" : "static", |
1432 st->index, &st->value); | 1432 st->index, &st->value); |
1433 | 1433 |
1434 rc = ngx_http_v3_ref_insert(c, st->dynamic, st->index, &st->value); | 1434 rc = ngx_http_v3_ref_insert(c, st->dynamic, st->index, &st->value); |
1435 if (rc != NGX_OK) { | 1435 if (rc != NGX_OK) { |
1440 return NGX_DONE; | 1440 return NGX_DONE; |
1441 } | 1441 } |
1442 | 1442 |
1443 | 1443 |
1444 static ngx_int_t | 1444 static ngx_int_t |
1445 ngx_http_v3_parse_header_iwnr(ngx_connection_t *c, | 1445 ngx_http_v3_parse_field_iln(ngx_connection_t *c, |
1446 ngx_http_v3_parse_header_t *st, u_char ch) | 1446 ngx_http_v3_parse_field_t *st, u_char ch) |
1447 { | 1447 { |
1448 ngx_int_t rc; | 1448 ngx_int_t rc; |
1449 enum { | 1449 enum { |
1450 sw_start = 0, | 1450 sw_start = 0, |
1451 sw_name_len, | 1451 sw_name_len, |
1458 switch (st->state) { | 1458 switch (st->state) { |
1459 | 1459 |
1460 case sw_start: | 1460 case sw_start: |
1461 | 1461 |
1462 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, | 1462 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
1463 "http3 parse header iwnr"); | 1463 "http3 parse field iln"); |
1464 | 1464 |
1465 st->literal.huffman = (ch & 0x20) ? 1 : 0; | 1465 st->literal.huffman = (ch & 0x20) ? 1 : 0; |
1466 st->state = sw_name_len; | 1466 st->state = sw_name_len; |
1467 | 1467 |
1468 /* fall through */ | 1468 /* fall through */ |
1530 return NGX_AGAIN; | 1530 return NGX_AGAIN; |
1531 | 1531 |
1532 done: | 1532 done: |
1533 | 1533 |
1534 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | 1534 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
1535 "http3 parse header iwnr done \"%V\":\"%V\"", | 1535 "http3 parse field iln done \"%V\":\"%V\"", |
1536 &st->name, &st->value); | 1536 &st->name, &st->value); |
1537 | 1537 |
1538 rc = ngx_http_v3_insert(c, &st->name, &st->value); | 1538 rc = ngx_http_v3_insert(c, &st->name, &st->value); |
1539 if (rc != NGX_OK) { | 1539 if (rc != NGX_OK) { |
1540 return rc; | 1540 return rc; |
1550 u_char ch) | 1550 u_char ch) |
1551 { | 1551 { |
1552 ngx_int_t rc; | 1552 ngx_int_t rc; |
1553 enum { | 1553 enum { |
1554 sw_start = 0, | 1554 sw_start = 0, |
1555 sw_ack_header, | 1555 sw_ack_section, |
1556 sw_cancel_stream, | 1556 sw_cancel_stream, |
1557 sw_inc_insert_count | 1557 sw_inc_insert_count |
1558 }; | 1558 }; |
1559 | 1559 |
1560 if (st->state == sw_start) { | 1560 if (st->state == sw_start) { |
1561 | 1561 |
1562 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, | 1562 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
1563 "http3 parse decoder instruction"); | 1563 "http3 parse decoder instruction"); |
1564 | 1564 |
1565 if (ch & 0x80) { | 1565 if (ch & 0x80) { |
1566 /* Header Acknowledgement */ | 1566 /* Section Acknowledgment */ |
1567 | 1567 |
1568 st->state = sw_ack_header; | 1568 st->state = sw_ack_section; |
1569 | 1569 |
1570 } else if (ch & 0x40) { | 1570 } else if (ch & 0x40) { |
1571 /* Stream Cancellation */ | 1571 /* Stream Cancellation */ |
1572 | 1572 |
1573 st->state = sw_cancel_stream; | 1573 st->state = sw_cancel_stream; |
1579 } | 1579 } |
1580 } | 1580 } |
1581 | 1581 |
1582 switch (st->state) { | 1582 switch (st->state) { |
1583 | 1583 |
1584 case sw_ack_header: | 1584 case sw_ack_section: |
1585 | 1585 |
1586 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 7, ch); | 1586 rc = ngx_http_v3_parse_prefix_int(c, &st->pint, 7, ch); |
1587 if (rc != NGX_DONE) { | 1587 if (rc != NGX_DONE) { |
1588 return rc; | 1588 return rc; |
1589 } | 1589 } |
1590 | 1590 |
1591 rc = ngx_http_v3_ack_header(c, st->pint.value); | 1591 rc = ngx_http_v3_ack_section(c, st->pint.value); |
1592 if (rc != NGX_OK) { | 1592 if (rc != NGX_OK) { |
1593 return rc; | 1593 return rc; |
1594 } | 1594 } |
1595 | 1595 |
1596 goto done; | 1596 goto done; |