# HG changeset patch # User Roman Arutyunyan # Date 1594632780 -10800 # Node ID e24f7b50ba1d4d47e4b5298d8aaf443ce94beb1f # Parent 5d2e285677a760cde558505332945db7259755b1 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. diff --git a/src/http/v3/ngx_http_v3_request.c b/src/http/v3/ngx_http_v3_request.c --- a/src/http/v3/ngx_http_v3_request.c +++ b/src/http/v3/ngx_http_v3_request.c @@ -774,14 +774,16 @@ ngx_http_v3_create_header(ngx_http_reque n = b->last - b->pos; - len = 1 + ngx_http_v3_encode_varlen_int(NULL, n); + len = ngx_http_v3_encode_varlen_int(NULL, NGX_HTTP_V3_FRAME_HEADERS) + + ngx_http_v3_encode_varlen_int(NULL, n); b = ngx_create_temp_buf(c->pool, len); if (b == NULL) { return NULL; } - *b->last++ = NGX_HTTP_V3_FRAME_HEADERS; + b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, + NGX_HTTP_V3_FRAME_HEADERS); b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, n); hl = ngx_alloc_chain_link(c->pool); @@ -793,7 +795,8 @@ ngx_http_v3_create_header(ngx_http_reque hl->next = cl; if (r->headers_out.content_length_n >= 0 && !r->header_only) { - len = 1 + ngx_http_v3_encode_varlen_int(NULL, + len = ngx_http_v3_encode_varlen_int(NULL, NGX_HTTP_V3_FRAME_DATA) + + ngx_http_v3_encode_varlen_int(NULL, r->headers_out.content_length_n); b = ngx_create_temp_buf(c->pool, len); @@ -801,7 +804,8 @@ ngx_http_v3_create_header(ngx_http_reque return NULL; } - *b->last++ = NGX_HTTP_V3_FRAME_DATA; + b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, + NGX_HTTP_V3_FRAME_DATA); b->last = (u_char *) ngx_http_v3_encode_varlen_int(b->last, r->headers_out.content_length_n);