Mercurial > hg > nginx
comparison src/http/v3/ngx_http_v3_request.c @ 8490:e24f7b50ba1d quic
HTTP/3: encode frame ids with ngx_http_v3_encode_varlen_int().
Even though typically frame ids fit into a single byte, calling
ngx_http_v3_encode_varlen_int() adds to the code clarity.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Mon, 13 Jul 2020 12:33:00 +0300 |
parents | 5d2e285677a7 |
children | e334ca1b23ba |
comparison
equal
deleted
inserted
replaced
8489:5d2e285677a7 | 8490:e24f7b50ba1d |
---|---|
772 cl->buf = b; | 772 cl->buf = b; |
773 cl->next = NULL; | 773 cl->next = NULL; |
774 | 774 |
775 n = b->last - b->pos; | 775 n = b->last - b->pos; |
776 | 776 |
777 len = 1 + ngx_http_v3_encode_varlen_int(NULL, n); | 777 len = ngx_http_v3_encode_varlen_int(NULL, NGX_HTTP_V3_FRAME_HEADERS) |
778 + ngx_http_v3_encode_varlen_int(NULL, n); | |
778 | 779 |
779 b = ngx_create_temp_buf(c->pool, len); | 780 b = ngx_create_temp_buf(c->pool, len); |
780 if (b == NULL) { | 781 if (b == NULL) { |
781 return NULL; | 782 return NULL; |
782 } | 783 } |
783 | 784 |
784 *b->last++ = NGX_HTTP_V3_FRAME_HEADERS; | 785 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, |
786 NGX_HTTP_V3_FRAME_HEADERS); | |
785 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, n); | 787 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, n); |
786 | 788 |
787 hl = ngx_alloc_chain_link(c->pool); | 789 hl = ngx_alloc_chain_link(c->pool); |
788 if (hl == NULL) { | 790 if (hl == NULL) { |
789 return NULL; | 791 return NULL; |
791 | 793 |
792 hl->buf = b; | 794 hl->buf = b; |
793 hl->next = cl; | 795 hl->next = cl; |
794 | 796 |
795 if (r->headers_out.content_length_n >= 0 && !r->header_only) { | 797 if (r->headers_out.content_length_n >= 0 && !r->header_only) { |
796 len = 1 + ngx_http_v3_encode_varlen_int(NULL, | 798 len = ngx_http_v3_encode_varlen_int(NULL, NGX_HTTP_V3_FRAME_DATA) |
799 + ngx_http_v3_encode_varlen_int(NULL, | |
797 r->headers_out.content_length_n); | 800 r->headers_out.content_length_n); |
798 | 801 |
799 b = ngx_create_temp_buf(c->pool, len); | 802 b = ngx_create_temp_buf(c->pool, len); |
800 if (b == NULL) { | 803 if (b == NULL) { |
801 return NULL; | 804 return NULL; |
802 } | 805 } |
803 | 806 |
804 *b->last++ = NGX_HTTP_V3_FRAME_DATA; | 807 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, |
808 NGX_HTTP_V3_FRAME_DATA); | |
805 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, | 809 b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, |
806 r->headers_out.content_length_n); | 810 r->headers_out.content_length_n); |
807 | 811 |
808 bl = ngx_alloc_chain_link(c->pool); | 812 bl = ngx_alloc_chain_link(c->pool); |
809 if (bl == NULL) { | 813 if (bl == NULL) { |