Welcome! Log In Create A New Profile

Advanced

range_filter_module get duplicated Accept-Ranges response headers

July 06, 2020 06:49AM
Hello,

Recently, we found if we use nginx slice module , and upstream server is such as a static file server, nginx will response duplicated `Accept-Ranges` headers if client request is not included range header.

the minimal config example as follow:

```
server {
listen 80;
server_name _;
default_type text/html;

location /get_file {
slice 256k;
proxy_set_header Range $slice_range;
proxy_pass http://127.0.0.1:8899;
}
}
```

use curl to get 1mb file:
```
curl -s http://localhost/get_file/1mb.test -D- -o /dev/null

HTTP/1.1 200 OK
Date: Mon, 06 Jul 2020 10:32:58 GMT
Content-Type: application/octet-stream
Content-Length: 1048576
Connection: keep-alive
Last-Modified: Mon, 06 Jul 2020 07:34:23 GMT
Cache-Control: public, max-age=43200
Expires: Mon, 06 Jul 2020 22:32:58 GMT
ETag: "1594020863.76-1048576-4019326287"
Accept-Ranges: bytes
Accept-Ranges: bytes
```

but if I add range header to curl request, will get expected response.

Then I review the ngx_http_range_filter_module, in `goto next_filter`( line 253) , should we handle NGX_HTTP_OK response? like:

```
next_filter:

if (r->headers_out.status == NGX_HTTP_OK) {
r->headers_out.accept_ranges = NULL;
return ngx_http_next_header_filter(r);
}

r->headers_out.accept_ranges = ngx_list_push(&r->headers_out.headers);
if (r->headers_out.accept_ranges == NULL) {
return NGX_ERROR;
}

r->headers_out.accept_ranges->hash = 1;
ngx_str_set(&r->headers_out.accept_ranges->key, "Accept-Ranges");
ngx_str_set(&r->headers_out.accept_ranges->value, "bytes");

return ngx_http_next_header_filter(r);
```

I am confused if it is a bug?
Subject Author Posted

range_filter_module get duplicated Accept-Ranges response headers

webber July 06, 2020 06:49AM

Re: range_filter_module get duplicated Accept-Ranges response headers

Roman Arutyunyan July 07, 2020 06:10AM

Re: range_filter_module get duplicated Accept-Ranges response headers

webber July 08, 2020 12:14AM

Re: range_filter_module get duplicated Accept-Ranges response headers

webber July 08, 2020 04:14AM

Re: range_filter_module get duplicated Accept-Ranges response headers

Roman Arutyunyan July 08, 2020 04:42AM

Re: range_filter_module get duplicated Accept-Ranges response headers

webber July 08, 2020 07:29AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 70
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready