Reputation: 559
First of all: I was trying to find a solution using stack overflow "similar questions" and google. Maybe I just didn't see it, but..
I wrote a PHP class which force file downloading. And give a header 'accept ranges: bytes'.
What am I doing wrong? Browser (Google Chrome) shows me zero progress and speed of downloading 0 kb/sec ( i decrease speed by sleep() func. ). But after Browser finish its download - in a moment shows me 100% progress. Why browser doesn't want to show its progress smoothly?
file downloader software works perfectly with this: shows correct progress, and can work with pause\resume download. Log of this software:
[17:27:50.347] Thread main : task started
[17:27:50.348] Thread main : thread 1 started
[17:27:50.348] Thread main : thread started
[17:27:50.349] Thread main : connecting
[17:27:50.350] Thread main : localhost:80
[17:27:50.351] Thread main : localhost:80
[17:27:50.351] Thread main : GET /fs-debug.png HTTP/1.1
Thread main : User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.77.4 (KHTML, like Gecko) Version/7.0 Safari/537.77.4
Thread main : Host: bonell
Thread main : Pragma: no-cache
Thread main : Accept: */*
Thread main : Connection: close
Thread main : Cache-Control: no-cache
Thread main : Referer: http://bonell/
[17:27:51.464] Thread main : HTTP/1.1 200 OK
Thread main : Date: Mon, 14 Sep 2015 14:27:50 GMT
Thread main : Server: Apache
Thread main : X-Powered-By: PHP/5.3.28
Thread main : Last-Modified: Mon, 14 Sep 2015 12:41:16 GMT
Thread main : Cache-Control: no-cache, must-revalidate
Thread main : Expires: Mon, 14 Sep 2015 14:27:50 GMT
Thread main : Cache-Control: post-check=0,pre-check=0
Thread main : Cache-Control: max-age=0
Thread main : Pragma: no-cache
Thread main : Connection: close
Thread main : Content-Transfer-Encoding: Binary
Thread main : Content-disposition: attachment; filename="tst.png"
Thread main : Accept-Ranges: bytes
Thread main : Content-Length: 27314
Thread main : Content-Type: image/png
[17:27:51.465] Thread main : saved to /Users/LINKeR/Downloads/fs-debug.1.png.folx/fs-debug.1.png
[17:27:51.466] Thread main : saved to /Users/LINKeR/Downloads/fs-debug.1.png.folx/fs-debug.1.png
[17:27:54.392] Thread main : socket closed
[17:27:54.393] Thread main : thread completed
[17:27:54.393] Thread main : thread 1 completed
[17:27:54.394] Thread main : task stopped
And after this I click "resume download" and it's works:
[17:34:17.379] Thread main : GET /fs-debug.png HTTP/1.1
Thread main : User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.77.4 (KHTML, like Gecko) Version/7.0 Safari/537.77.4
Thread main : Host: bonell
Thread main : Pragma: no-cache
Thread main : Accept: */*
Thread main : Connection: close
Thread main : Cache-Control: no-cache
Thread main : Referer: http://bonell/
[17:34:19.420] Thread main : HTTP/1.1 200 OK
Thread main : Date: Mon, 14 Sep 2015 14:34:17 GMT
Thread main : Server: Apache
Thread main : X-Powered-By: PHP/5.3.28
Thread main : Last-Modified: Mon, 14 Sep 2015 12:41:16 GMT
Thread main : Cache-Control: no-cache, must-revalidate
Thread main : Expires: Mon, 14 Sep 2015 14:34:18 GMT
Thread main : Cache-Control: post-check=0,pre-check=0
Thread main : Cache-Control: max-age=0
Thread main : Pragma: no-cache
Thread main : Connection: close
Thread main : Content-Transfer-Encoding: Binary
Thread main : Content-disposition: attachment; filename="tst.png"
Thread main : Accept-Ranges: bytes
Thread main : Content-Length: 27314
Thread main : Content-Type: image/png
[17:34:19.421] Thread main : socket closed
[17:34:19.421] Thread main : Checking Size
[17:34:19.422] Thread main : connecting
[17:34:19.423] Thread main : localhost:80
[17:34:19.423] Thread main : localhost:80
[17:34:19.424] Thread main : GET /fs-debug.png HTTP/1.1
Thread main : User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.77.4 (KHTML, like Gecko) Version/7.0 Safari/537.77.4
Thread main : Host: bonell
Thread main : Pragma: no-cache
Thread main : Accept: */*
Thread main : Connection: close
Thread main : Cache-Control: no-cache
Thread main : Range: bytes=4096-
Thread main : Referer: http://bonell/
[17:34:19.462] Thread main : HTTP/1.1 206 Partial Content
Thread main : Date: Mon, 14 Sep 2015 14:34:19 GMT
Thread main : Server: Apache
Thread main : X-Powered-By: PHP/5.3.28
Thread main : Last-Modified: Mon, 14 Sep 2015 12:41:16 GMT
Thread main : Cache-Control: no-cache, must-revalidate
Thread main : Expires: Mon, 14 Sep 2015 14:34:19 GMT
Thread main : Cache-Control: post-check=0,pre-check=0
Thread main : Cache-Control: max-age=0
Thread main : Pragma: no-cache
Thread main : Connection: close
Thread main : Content-Transfer-Encoding: Binary
Thread main : Content-disposition: attachment; filename="tst.png"
Thread main : Accept-Ranges: bytes
Thread main : Content-Range: bytes 4096-27313/27314
Thread main : Transfer-Encoding: chunked
Thread main : Content-Type: image/png
[17:34:19.463] Thread main : saved to /Users/LINKeR/Downloads/fs-debug.1.png.folx/fs-debug.1.png
Upvotes: 2
Views: 237
Reputation: 3010
This question is already answered in the comments but I'll report it here for future reference.
It looks like that Chrome, even with all the correct headers in place (Content-Length
and Accept-Ranges: bytes
), disables progress reporting and download resuming for small sized files.
Try with a bigger file and it should work.
Upvotes: 1