masterzen / nginx-upload-progress-module

Nginx module implementing an upload progress system, that monitors RFC1867 POST uploads as they are transmitted to upstream servers.
http://wiki.codemongers.com/NginxHttpUploadProgressModule
Other
432 stars 101 forks source link

fix received and size same issue when using HTTP/2 #55

Closed e2dk4r closed 2 years ago

e2dk4r commented 2 years ago

this changes fix received value same as size value in responses when using HTTP/2

bug mentioned at masterzen/nginx-upload-progress-module#45

e2dk4r commented 2 years ago

The reason this bug accours is request body rb->rest is returning 1 when HTTP/2 is enabled. You can find this in src/http/v2/ngx_http_v2.c in ngx_http_v2_read_request_body function on rb->rest = 1; line.

ngx_int_t
ngx_http_v2_read_request_body(ngx_http_request_t *r)
{
    off_t                      len;
    size_t                     size;
    ngx_buf_t                 *buf;
    ngx_int_t                  rc;
    ngx_http_v2_stream_t      *stream;
    ngx_http_v2_srv_conf_t    *h2scf;
    ngx_http_request_body_t   *rb;
    ngx_http_core_loc_conf_t  *clcf;
    ngx_http_v2_connection_t  *h2c;

    stream = r->stream;
    rb = r->request_body;

    if (stream->skip_data) {
        r->request_body_no_buffering = 0;
        rb->post_handler(r);
        return NGX_OK;
    }

    rb->rest = 1;
    ...

https://github.com/nginx/nginx/blob/e0086aaeea3810b5485f53d2f38f74cc74effea7/src/http/v2/ngx_http_v2.c#L4009-L4031