Welcome! Log In Create A New Profile

Advanced

Re:[patch] Slice filter: support for empty file.

胡聪 (hucc)
June 19, 2017 10:42PM
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 <hucong.c@foxmail.com>
># 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 <hucong.c@foxmail.com>
# 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
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[patch] Slice filter: support for empty file.

胡聪 (hucc) 486 June 19, 2017 02:26PM

Re:[patch] Slice filter: support for empty file.

胡聪 (hucc) 216 June 19, 2017 10:42PM

Re: [patch] Slice filter: support for empty file.

Maxim Dounin 265 June 20, 2017 11:02AM

Re: [patch] Slice filter: support for empty file.

胡聪 (hucc) 238 June 21, 2017 01:26PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 190
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready