Closed (fixed)
Project:
Fast File Transfer with X-send file
Version:
6.x-2.3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
31 May 2010 at 17:41 UTC
Updated:
27 Jul 2010 at 09:10 UTC
i was wondering why the module is not working here, so i took a look into the code.
dsm(apache_get_modules()); -> mod_xsendfile is listed
in_array() -> Returns TRUE if needle is found in the array, FALSE otherwise.
if(in_array('mod_xsendfile', apache_get_modules()) ) {
drupal_set_message('X-send file module for apache2 is not installed in your system. Untill you correctly install it do not enable this module.', 'error');
}
This means that the function gives an error if the module is found. It should be !in_array() i think.
Comments
Comment #1
marcoka commentedany opinion?
Comment #2
marcoka commentedalready posted here: http://drupal.org/node/658294
not fixed after so long time.
i would not recommend using this module because its documentation is very bad. and in my case i can not see any x-sendfile headers on my install using a clean drupal and debain lenny with mod_xsendfile. and its not possible to enable it without fixing the obove mentioned bug.
Comment #3
marcoka commentedI tested the functionality of the file_transfer hook, and my result was that the X-Sendfile header is not beeing set, so i added 2 testheaders , first and second around it and voila they appear.
function xsend_file_transfer() {
if (variable_get('file_transfer_handler', "file_transfer_default") == 'file_transfer_default') {
$args = func_get_args();
call_user_func_array('file_download', $args);
exit();
}
// Merge remainder of arguments from GET['q'], into relative file path.
$args = func_get_args();
$filepath = implode('/', $args);
if (file_exists(file_create_path($filepath))) {
$headers = module_invoke_all('file_download', $filepath);
if (in_array(-1, $headers)) {
return drupal_access_denied();
}
if (count($headers)) {
// drupal_set_header('X-Sendfile: '. realpath(file_create_path($filepath)));
foreach ($headers as $header) {
// To prevent HTTP header injection, we delete new lines that are
// not followed by a space or a tab.
// See http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
$header = preg_replace('/\r?\n(?!\t| )/', '', $header);
drupal_set_header($header);
}
header('first: '. realpath(file_create_path($filepath)));
header('X-Sendfile: '. realpath(file_create_path($filepath)));
header('second: '. realpath(file_create_path($filepath)));
exit();
}
}
return drupal_not_found();
}
Header result:
HTTP/1.1 200 OK
Date: Thu, 17 Jun 2010 16:34:53 GMT
Server: Apache
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Sun, 13 Jun 2010 16:09:36 GMT
Cache-Control: public
Content-Disposition: attachment; filename="foo.png"
first: /var/www/web/WORKSPACE_DRUPAL/artwaves_drupal_texturesite_public/sites/default/files/privatefiles/foo.png
second: /var/www/web/WORKSPACE_DRUPAL/artwaves_drupal_texturesite_public/sites/default/files/privatefiles/foo.png
Etag: "1dc509-2b86d-488eb99363000;4890e82644740"
Vary: Accept-Encoding
Content-Encoding: gzip
Keep-Alive: timeout=3, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
I checked if sendfile is working, to do taht i made a script and called it:
Header result:
HTTP/1.1 200 OK
Date: Thu, 17 Jun 2010 14:38:52 GMT
Server: Apache
X-Sendfile: /var/www/web/test.jpg
Content-Disposition: attachment; filename="test.jpg"
Content-Length: 0
Keep-Alive: timeout=3, max=100
Connection: Keep-Alive
Content-Type: application/octet-stream
So whats wrong here.
Comment #4
hypertext200The issue fixed in Dev version, we will create a new version soon, and I need to test the headers again. This worked for me.
Comment #5
hypertext200Here what I have used is override the system/files URL to handle this, this should work if your in private file system.
Comment #6
marcoka commentedi did some research:
Its seems that something like "X-Sendfile: /var/www/web/test.jpg" will not appear in the header because this would show what the system is using and will be a bit of a security issue. I read that the X-Sendfile header is discarded on the server and then sent with a new header without the "X-Senndfile" part
Can you confirm that? I use "live http headers" for firefox to view the headers.
Comment #7
marcoka commentedi am not but i rewrite some files to /system/files/foo to secure them/access checking.
The function xsend_file_transfer is called (i see that in xdebug). My only question left is the header thing above posted
Comment #8
hypertext200I have installed this in several clients, they are working very cool and fast. But I cannot see the X-send header there.
Comment #9
marcoka commentedthank you, the my guessing above was right.
Comment #10
marcoka commented