Hi,
I have been experiencing problems with gzip compression and php, and I kind
of isolate the problem by transfering a file via php.
I set up the headers and send a file like this (implementing private file
system):
$headers = array(
'Pragma: public',
'Expires: 0',
'Cache-Control: must-revalidate, post-check=0, pre-check=0, private',
'Content-Type: '. mime_header_encode($filemime),
'Content-Length: '. $filesize,
'Content-Disposition: inline;',
'Content-Transfer-Encoding: binary',
);
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);
header($header);
}
// $source is the path to the file
// Transfer file in 1024 byte chunks to save memory usage.
if ($fd = fopen($source, 'rb')) {
if (!ini_get('safe_mode')) {
set_time_limit(0);
}
while (!feof($fd)) {
print fread($fd, 1024);
}
fclose($fd);
}
exit();
Without gzip compression in encoding in the php behavior I get the correct
headers, for example:
1. Cache-Control:
post-check=0, pre-check=0, must-revalidate, post-check=0, pre-check=0,
private
2. Connection:
Keep-Alive
3. Content-Disposition:
inline;
4. Content-Length:
6514014
5. Content-Transfer-Encoding:
binary
6. Content-Type:
application/octet-stream
7. Date:
Mon, 19 Oct 2009 18:31:55 GMT
8. Expires:
0
9. Keep-Alive:
timeout=1000
10. Last-Modified:
Mon, 19 Oct 2009 18:31:55 GMT
11. Pragma:
public
12. Server:
Cherokee/0.99.24 (Ubuntu)
13. X-Powered-By:
PHP/5.2.6-3ubuntu4.2
Adding gzip compression in encoding in the php behavior I do not get the
content-length when sending the file:
1. Cache-Control:
post-check=0, pre-check=0, must-revalidate, post-check=0, pre-check=0,
private
2. Connection:
Keep-Alive
3. Content-Disposition:
inline;
4. Content-Encoding:
gzip
5. Content-Transfer-Encoding:
binary
6. Content-Type:
application/octet-stream
7. Date:
Mon, 19 Oct 2009 18:35:36 GMT
8. Expires:
0
9. Keep-Alive:
timeout=1000
10. Last-Modified:
Mon, 19 Oct 2009 18:35:36 GMT
11. Pragma:
public
12. Server:
Cherokee/0.99.24 (Ubuntu)
13. Transfer-Encoding:
Identity
14. Vary:
Accept-Encoding
15. X-Powered-By:
PHP/5.2.6-3ubuntu4.2
I do not know what is the real problem, and do not know how to "debug", if
this is cherokee issue, php, etc...
Thanks for the help!
_______________________________________________
Cherokee mailing list
[email protected]
http://lists.octality.com/listinfo/cherokee