changeset 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 6e1798a4a0d2
files src/http/v3/ngx_http_v3_request.c
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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);