1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-08-17 21:31:42 +02:00

always send last-modified header

This commit is contained in:
Mikael Roos
2013-10-14 09:22:21 +02:00
parent c03ebedc93
commit 7117ac2a4c
4 changed files with 18 additions and 10 deletions

View File

@@ -275,9 +275,12 @@ EOD;
$info = list($width, $height, $type, $attr) = getimagesize($file);
!empty($info) or $this->RaiseError("The file doesn't seem to be an image.");
$mime = $info['mime'];
$time = filemtime($file);
$lastModified = filemtime($file);
$gmdate = gmdate("D, d M Y H:i:s", $lastModified);
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $time){
if(!$this->verbose) { header('Last-Modified: ' . $gmdate . " GMT"); }
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified){
if($this->verbose) {
$this->Log("304 not modified");
$this->VerboseOutput();
@@ -285,8 +288,6 @@ EOD;
}
header("HTTP/1.0 304 Not Modified");
} else {
$gmdate = gmdate("D, d M Y H:i:s", $time);
if($this->verbose) {
$this->Log("Last modified: " . $gmdate . " GMT");
$this->VerboseOutput();
@@ -294,7 +295,6 @@ EOD;
}
header('Content-type: ' . $mime);
header('Last-Modified: ' . $gmdate . " GMT");
readfile($file);
}
exit;