Mod_xsendfile Firefox resumes release

We are trying to use mod_xsendfile with Apache to effectively manage large file downloads (> 1 GB). After installation, the configuration is as follows:

<IfModule mod_xsendfile.c>
<Directory "/abs_path/to/dl">
    XSendFile on
    XSendFilePath /abs_path/to/files_dir
</Directory> 
</IfModule>

The download script does not represent anything, it simply checks for the presence of the file to download and sets the headers according to the documentation, for example:

header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
header("X-Sendfile: " . $file);

Continuous downloads work great with any user agent we tested with, and HTTP-Range works fine with everyone except Firefox (tested versions 27 and 28). Firefox may pause the download, but the resume is interrupted every time.

These are the http headers recorded with the Live HTTP Header Extension:

Bootstrap:

http://www.oursite.com/dl/test-xs.php?ID=TestFileID

GET /dl/test-xs.php?ID=TestFileID HTTP/1.1
Host: www.oursite.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: some cookie string...
Connection: keep-alive

HTTP/1.1 200 OK
Date: Tue, 25 Mar 2014 10:22:46 GMT
Server: Apache
X-Powered-By: PHP/5.3.28
Content-Disposition: attachment; filename="TestFile.ext"
Last-Modified: Sun, 02 Mar 2014 18:20:36 GMT
Content-Length: 84406272
Connection: close
Content-Type: application/octet-stream

... and when Firefox tries to resume:

http://www.oursite.com/dl/test-xs.php?ID=TestFileID

GET /dl/test-xs.php?ID=TestFileID HTTP/1.1
Host: www.oursite.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: same cookie string...
Connection: keep-alive
Range: bytes=11238434-
If-Unmodified-Since: Sun, 02 Mar 2014 18:20:36 GMT

... the server returns 404

HTTP/1.1 404 Not Found
Date: Tue, 25 Mar 2014 10:23:03 GMT
Server: Apache
X-Powered-By: PHP/5.3.28, PHP/5.3.28
Content-Disposition: attachment; filename="TestFile.ext"
X-Sendfile: /abs_path/to/files_dir/TestFile.ext
X-Pingback: http://www.oursite.com/xmlrpc.php
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

... , , Firefox ( ).

, , , , :

  • - ?
  • - script ?

Edit

, If-Unmodified-Since, Firefox . , Last-Modified , Apache, - 404. If-Unmodified-Since .htaccess:

<Files test-xs.php>
  RequestHeader unset If-Unmodified-Since
</Files>

... , Firefox.

, , , , , .

, , , , , , , .

:

  • ?
  • mod_xsend?
+4
2

@alternize , :

SetEnvIf Range .+ HAS_RANGE_HEADER
RequestHeader unset If-Range env=!HAS_RANGE_HEADER
RequestHeader unset If-Unmodified-Since env=!HAS_RANGE_HEADER

, Range.

"!" , Range.

If-Range If-Unmodified-Since Range, , :

SetEnvIf Range .+ HAS_RANGE_HEADER
RequestHeader unset If-Range env=HAS_RANGE_HEADER
RequestHeader unset If-Unmodified-Since env=HAS_RANGE_HEADER

apache 2.2.15.

+1

mod_xsend , . , chrome "If-Range" "Range":

:

GET /foo.webm

Range: bytes=0-

:

206 Partial Content

Content-Length: 54376097
Content-Range: bytes 0-54376096/54376097
Content-Type: video/webm
ETag: "78976c9d1a595cba56e24bec6f2f1178"

= >

:

GET /foo.webm

If-Range: "78976c9d1a595cba56e24bec6f2f1178"
Range: bytes=54373845-54376096

:

200 OK

Content-Length: 54376097
ETag: "78976c9d1a595cba56e24bec6f2f1178"

= >

, "Range":

SetEnvIf Range .+ HAS_RANGE_HEADER
RequestHeader unset If-Range env=!HAS_RANGE_HEADER
RequestHeader unset If-Unmodified-Since env=!HAS_RANGE_HEADER
0

Source: https://habr.com/ru/post/1533314/


All Articles