我正在寻找一种方法来确认X-Sendfile是否正确处理由脚本(PHP)返回给Web服务器的请求.图像正在正确提供,但我想我会在curl请求中看到标题.
$ curl -I http://blog2.stageserver.net/wp-includes/ms-files.php?file=/2011/05/amos-lee-feature.jpg
HTTP/1.1 200 OK
Date: Wed, 04 Jan 2012 17:19:45 GMT
Server: Cherokee/1.2.100 (Arch Linux)
ETag: "4dd2e306=9da0"
Last-Modified: Tue, 17 May 2011 21:05:10 GMT
Content-Type: image/jpeg
Content-Length: 40352
X-Powered-By: PHP/5.3.8
Content-Disposition: inline; filename="amos-lee-feature.jpg"
Run Code Online (Sandbox Code Playgroud)
在FastCGI中使用PHP-FPM 5.3.8的Cherokee 1.2.100 :(
cherokee.conf: vserver!20!rule!500!handler!xsendfile = 1
由vServer> Behavior> Extensions设置php> Handler:允许X-Sendfile [check Enabled])
Wordpress网络/ WPMU 3.3.1:
define('WPMU_SENDFILE',true);在包含wp-config.php之前设置如下wp-settings.php.这将触发以下代码在WP的wp-includes/ms-files.php中执行:50为特定博客提供文件:
header( 'X-Sendfile: ' . $file );
exit;
Run Code Online (Sandbox Code Playgroud)
我已经确认上面的代码片段正在通过在exit();调用之前添加一个用于处置的附加标头来执行.Content-Disposition与curl结果一起出现,而不是最初在ms-files.php代码中.添加的代码是:
header('Content-Disposition: inline; filename="'.basename($file).'"');
我有: …