summaryrefslogtreecommitdiff
path: root/inc/pageutils.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2009-01-22 22:50:10 +0100
committerAndreas Gohr <andi@splitbrain.org>2009-01-22 22:50:10 +0100
commit98bda4fdc7bccbef714bd6480528804bcd3f5586 (patch)
tree7f26270babd142e6024f2988e5c8f489dd483a49 /inc/pageutils.php
parentd578eae7de9837d20a73ae2f83f7bf3d346d7ed5 (diff)
downloadrpg-98bda4fdc7bccbef714bd6480528804bcd3f5586.tar.gz
rpg-98bda4fdc7bccbef714bd6480528804bcd3f5586.tar.bz2
fixed multiple gzip/sendfile problems in css and js dispatchers FS#1571
- Avoid double compression when gzip_output is enabled - Only compress when gzip_output is enabled - Do not use x-sendfile for compressed content (content-encoding is not supported) - Make sure the script terminates after using x-sendfile - Moved gzip browser support check to init.php darcs-hash:20090122215010-7ad00-765765d353ff78df5b8704086328c5c699bbe7e0.gz
Diffstat (limited to 'inc/pageutils.php')
-rw-r--r--inc/pageutils.php31
1 files changed, 17 insertions, 14 deletions
diff --git a/inc/pageutils.php b/inc/pageutils.php
index 5fea66942..4a62244dc 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -534,7 +534,7 @@ function isVisiblePage($id){
* @author Simon Willison <swillison@gmail.com>
* @link http://simon.incutio.com/archive/2003/04/23/conditionalGet
* @param timestamp $timestamp lastmodified time of the cache file
- * @returns void or void with previously header() commands executed
+ * @returns void or exits with previously header() commands executed
*/
function http_conditionalRequest($timestamp){
// A PHP implementation of conditional get, see
@@ -579,7 +579,10 @@ function http_conditionalRequest($timestamp){
}
/**
- * common routines for handling communication with the client (browser)
+ * Let the webserver send the given file vi x-sendfile method
+ *
+ * @author Chris Smith <chris.eureka@jalakai.co.uk>
+ * @returns void or exits with previously header() commands executed
*/
function http_sendfile($file) {
global $conf;
@@ -587,28 +590,28 @@ function http_sendfile($file) {
//use x-sendfile header to pass the delivery to compatible webservers
if($conf['xsendfile'] == 1){
header("X-LIGHTTPD-send-file: $file");
- return true;
+ ob_end_clean();
+ exit;
}elseif($conf['xsendfile'] == 2){
header("X-Sendfile: $file");
- return true;
+ ob_end_clean();
+ exit;
}elseif($conf['xsendfile'] == 3){
header("X-Accel-Redirect: $file");
- return true;
+ ob_end_clean();
+ exit;
}
return false;
}
-function http_accepts_gzip() {
- return !empty($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip') !== false);
-}
-
-function http_accepts_deflate() {
- return !empty($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'deflate') !== false);
-}
/**
- * return true if there exists a gzip version of the uncompressed file (samepath/samefilename.sameext.gz)
- * created after the uncompressed file
+ * Check for a gzipped version and create if necessary
+ *
+ * return true if there exists a gzip version of the uncompressed file
+ * (samepath/samefilename.sameext.gz) created after the uncompressed file
+ *
+ * @author Chris Smith <chris.eureka@jalakai.co.uk>
*/
function http_gzip_valid($uncompressed_file) {
$gzip = $uncompressed_file.'.gz';