nginx-upload-progress-module icon indicating copy to clipboard operation
nginx-upload-progress-module copied to clipboard

Wrong fix

Open doublex opened this issue 11 years ago • 2 comments

Hello,

The commit "aa4e8b93558274a45387d215740a6bd4654148f4" has a bug. If I upload a file, the code enters the first "if()", but not the second "if()", so "up->rest" is zero, but "up->length" is not. Therefore the module reports in the beginning 100% uploaded because up->rest == 0.

Thanks a lot!

    /* Properly handles small files where no read events happen after the */
    /* request is first handled (apparently this can happen on linux with epoll) */
    if (r->headers_in.content_length_n) {
        up->length = r->headers_in.content_length_n;
        if (r->request_body) {
            up->rest = r->request_body->rest;
        }
    }

doublex avatar Sep 20 '14 19:09 doublex

I met the same problem. and i fixed it as follows. it tested ok.

if (r->headers_in.content_length_n) {
    up->length = r->headers_in.content_length_n;
     if (r->request_body) {
         up->rest = r->request_body->rest;
     } else {
         up->rest = up->length;
     }
 }

ChenyuanHu avatar Sep 22 '14 07:09 ChenyuanHu

@ChenyuanHu or @doublex, would you open a Pull Request with the fix so that I can merge it ASAP?

masterzen avatar Sep 29 '14 13:09 masterzen