My server hosts large files to download (the files may stored in different file severs but not in the web server). My intention is to let browser use partial download so that the web server can fetch the small piece of the file instead the whole file.
But the the browser (chrome 66) sent the first HTTP GET request without Range
. So I MUST reply with Status: 200 OK
.
Request:
GET http://fakefile/falke HTTP/1.1
Host: fakefile
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 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
Accept-Language: zh-CN,zh;q=0.9
Respond Trail #1:
HTTP/1.1 200 OK
Date: Tue, 12 Jun 2018 04:58:58 GMT
Content-Type: text/plain
Content-Length: 8205926
Connection: keep-alive
Content-Range: bytes 0-1048575/8205926
Content-Disposition: attachment; filename="301050.11051.input.txt"
Accept-Ranges: bytes
The Content-Length
is the whole file size, the Content-Range
is the chunk size.
Result: The browser regards the chunk is the whole file, and no more HTTP range requests.
Respond Trail #2:
HTTP/1.1 206 Partial Content
Date: Tue, 12 Jun 2018 04:58:58 GMT
Content-Type: text/plain
Content-Length: 1048576
Connection: keep-alive
Content-Range: bytes 0-1048575/8205926
Content-Disposition: attachment; filename="301050.11051.input.txt"
Accept-Ranges: bytes
The Content-Length
is the chunk size, the Content-Range
is the chunk size.
Result: The browser tells file not downloaded.
QUESTION:
How can I respond the request to send the first chunk of the large file. And the browser can automatically download the remain chunks using partial content.