[PATCH] HTTP/3: fixed $body_bytes_sent

Sergey Kandaurov pluknet at nginx.com
Fri Jun 23 10:02:01 UTC 2023


> On 20 Jun 2023, at 17:43, Sergey Kandaurov <pluknet at nginx.com> wrote:
> 
> # HG changeset patch
> # User Sergey Kandaurov <pluknet at nginx.com>
> # Date 1687268079 -14400
> #      Tue Jun 20 17:34:39 2023 +0400
> # Node ID a95bffe430283bf25341ad9745ffe1199e7c2190
> # Parent  bf4bd5af4d7fdadab83616be9218604b658e3d84
> HTTP/3: fixed $body_bytes_sent.
> 
> diff --git a/src/http/v3/ngx_http_v3_filter_module.c b/src/http/v3/ngx_http_v3_filter_module.c
> --- a/src/http/v3/ngx_http_v3_filter_module.c
> +++ b/src/http/v3/ngx_http_v3_filter_module.c
> @@ -540,6 +540,8 @@ ngx_http_v3_header_filter(ngx_http_reque
>     *ll = hl;
>     ll = &cl->next;
> 
> +    r->header_size = n + (b->last - b->pos);
> +
>     if (r->headers_out.content_length_n >= 0
>         && !r->header_only && !r->expect_trailers)
>     {

This variant of the patch additionally cuts off the first (and only) DATA
frame header length from the variable value.  This better matches HTTP/1.1
non-"chunked transfer encoding" behaviour, when the content length is known
and no trailers expected.  Else, when chunked is used, all DATA-frame header
lengths (and trailers) are included similar to HTTP/1.1.

# HG changeset patch
# User Sergey Kandaurov <pluknet at nginx.com>
# Date 1687514427 -14400
#      Fri Jun 23 14:00:27 2023 +0400
# Node ID c681f4906d838ac45b517fada4c4274ade03fd3c
# Parent  77c1418916f7817a0d020f28d8a08f278a12fe43
HTTP/3: fixed $body_bytes_sent.

diff --git a/src/http/v3/ngx_http_v3_filter_module.c b/src/http/v3/ngx_http_v3_filter_module.c
--- a/src/http/v3/ngx_http_v3_filter_module.c
+++ b/src/http/v3/ngx_http_v3_filter_module.c
@@ -581,6 +581,7 @@ ngx_http_v3_header_filter(ngx_http_reque
 
     for (cl = out; cl; cl = cl->next) {
         h3c->total_bytes += cl->buf->last - cl->buf->pos;
+        r->header_size += cl->buf->last - cl->buf->pos;
     }
 
     return ngx_http_write_filter(r, out);

-- 
Sergey Kandaurov


More information about the nginx-devel mailing list