Hi, >416 will be returned when the request has no Range HEADER and the target file >is >empty. Apparently, it does not conform to the HTTP protocol. Empty file seems >inevitable in the CDN service where Nginx is heavily used. > ># HG changeset patch ># User hucongcong <[email protected]> ># Date 1497892764 -28800 ># Tue Jun 20 01:19:24 2017 +0800 ># Node ID 79d38b2d27d4eb92395cf1ff43bbfe23498bc69a ># Parent d1816a2696de8c2faa1cd913a151e5f62a8620f3 >Slice filter: support for empty file.
The following modifications may be more appropriate. # HG changeset patch # User hucongcong <[email protected]> # Date 1497926137 -28800 # Tue Jun 20 10:35:37 2017 +0800 # Node ID e42abb7e28c4f0dd3d66cb81aa2623e7fae8b4da # Parent a39bc74873faf9e5bea616561b43f6ecc55229f9 Slice filter: support for empty file. diff -r a39bc74873fa -r e42abb7e28c4 src/http/modules/ngx_http_slice_filter_module.c --- a/src/http/modules/ngx_http_slice_filter_module.c Mon Jun 19 14:25:42 2017 +0300 +++ b/src/http/modules/ngx_http_slice_filter_module.c Tue Jun 20 10:35:37 2017 +0800 @@ -114,7 +114,21 @@ ngx_http_slice_header_filter(ngx_http_re } if (r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT) { + if (r == r->main) { + if (r->headers_in.range == NULL + && r->headers_out.status == NGX_HTTP_RANGE_NOT_SATISFIABLE) + { + r->header_only = 1; + ngx_str_null(&r->headers_out.content_type); + + r->headers_out.status = NGX_HTTP_OK; + r->headers_out.status_line.len = 0; + r->headers_out.content_length_n = 0; + r->headers_out.content_range->hash = 0; + r->headers_out.content_range = NULL; + } + ngx_http_set_ctx(r, NULL, ngx_http_slice_filter_module); return ngx_http_next_header_filter(r); } _______________________________________________ nginx-devel mailing list [email protected] http://mailman.nginx.org/mailman/listinfo/nginx-devel
