New issue
Advanced search Search tips

Issue 823351 link

Starred by 2 users

Issue metadata

Status: Started
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 3
Type: Bug



Sign in to add a comment

Downloads do not respect "Accept-Ranges: none" header

Project Member Reported by freedjm@chromium.org, Mar 19 2018

Issue description

When Chrome is downloading from a webserver, and the webserver sends the "Accept-Ranges: none" header, Chrome ignores the header and still sends range requests.

This bug was found while investigating https://bugs.chromium.org/p/chromium/issues/detail?id=817848.

We'll use a similar repo process to what is used in the aforementioned bug. We'll use netcat (nc) to act as a webserver and have Chrome (65.0.3325.146) download from it.

First, we'll use the file 'resp' to serve content from nc. A copy of 'resp' is attached. It's headers look like:

$ head -7 resp
HTTP/1.1 200 OK
Content-Type: application/binary
Content-Encoding: gzip
Content-Length: 297
Accept-Ranges: none
ETag: foo


Then we can start netcat listening on port 8080 and serving 'resp'. And we can see the request received from Chrome when we navigate to http://localhost:8080/foobar.

$ nc -l 8080 < resp
GET /foobar HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

^C

The download will not complete because the content in 'resp' is not complete. So it is as if the webserver terminates the connection. Then to see the resume request, restart nc listening on port 8080 and then manually resume the download in Chrome.

$ nc -l 8080
GET /foobar HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Range: bytes=368-
If-Range: foo
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

^C

As we can see from that request, Chrome is still sending a range request, even though the webserver specified "Accept-Ranges: none".



 
resp
374 bytes View Download
Owner: xingliu@chromium.org
Status: Assigned (was: Untriaged)
Status: Started (was: Assigned)

Comment 3 Deleted

We do handle "Accept-Ranges: none" on first time request in:

https://chromium.googlesource.com/chromium/src/+/65.0.3325.188/content/browser/download/download_utils.cc#409

On resumption request, Chrome download always uses "If-Range" header.
https://tools.ietf.org/html/rfc7233#section-3.2

Quite for a while, even in M58.
https://chromium.googlesource.com/chromium/src/+/58.0.2999.2/content/browser/download/download_request_core.cc#168

This logic will work if we don't persist etag and last-modified header for request without "Accept-Range:bytes", I guess that's not true that we always persist the etag in:

https://chromium.googlesource.com/chromium/src/+/58.0.2999.2/content/browser/download/download_request_core.cc#312


If the server returns HTTP 200 and entire entity body, it will work.

I think in RFC, the server can ignore Range request, and provides full entity with HTTP 200. It doesn't specify the server should fail if it received range request but can't response a partial content.
Because the If-Range header, this is mostly working as expected.

The reality might be that most servers will return HTTP 200 and full entity body when they can't handle "If-Range" and "Range" combination.
Ah ok, I guess this was only a problem for us because we were trying to modify the behavior of the client (i.e. don't send us any range requests) using "Accept-Ranges: none" when in fact this is not what the header is meant to do.
Cc: qin...@chromium.org
Sorry to be off topic, but https://bugs.chromium.org/p/chromium/issues/detail?id=737617 seems pretty related and could do with an owner.

Sign in to add a comment