Upload Module - add response header with MD5

Francis Daly francis at daoine.org
Mon Aug 20 19:18:59 UTC 2012

On Mon, Aug 20, 2012 at 03:28:59AM -0400, mokriy wrote:

Hi there,

> Basically, I am using the one from Valeriy Kholodkov:
> http://www.grid.net.ru/nginx/upload.ru.html
> upload_add_header feature appeared in v 2.2, I guess:

Ah, you're using a development work-in-progress version.

upload_add_header is not in the released 2.2.0 tarball.

> https://github.com/vkholodkov/nginx-upload-module/blob/2.2/ngx_http_upload_module.c
> I can find it in C code - 'upload_add_header'.

I guess you've found a bug in the development code.

> However the MD5 hashes returned in response header are.. not hashes.
> They are:
> 34383765656261393461336230613362 OR
> 34396436323764343839623564646664

It looks like it isn't a new bug in the post-2.2.0 code; but
upload_add_header makes it easier to expose.

It appears that (at least) for the aggregate variables, accessing one
more than once will cause the previous value to be read as bytes, and
written in hexadecimal ascii representation.

So in your first example above, the md5sum began 487eeba94a3b0a3b.

Test with something like

    upload_aggregate_form_field "${upload_field_name}_md5" $upload_file_md5;
    upload_aggregate_form_field "${upload_field_name}_md6" $upload_file_md5;
    upload_aggregate_form_field "${upload_field_name}_md7" $upload_file_md5;
    upload_aggregate_form_field "${upload_field_name}_md8" $upload_file_md5;

and you'll see that the later values include increasing strings of 3s.

(Of course, it was never sane to use $upload_file_md5 more than once,
so this didn't matter. But now it is, and it does.)

Francis Daly        francis at daoine.org

More information about the nginx mailing list