From 236ebace73232bcb4d15d7466f67f3f4566b8429 Mon Sep 17 00:00:00 2001 From: Patrick Allaert Date: Thu, 22 Mar 2012 19:26:35 +0100 Subject: [PATCH] Fixed #019247: Pause/Resuming a download not working in firefox --- lib/ezfile/classes/ezfile.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ezfile/classes/ezfile.php b/lib/ezfile/classes/ezfile.php index 7db63932b57..170dd2f21dd 100644 --- a/lib/ezfile/classes/ezfile.php +++ b/lib/ezfile/classes/ezfile.php @@ -269,13 +269,15 @@ public static function downloadHeaders( $file, $isAttachedDownload = true, $over } header( 'X-Powered-By: eZ Publish' ); - header( "Content-Length: $fileSize" ); $mimeinfo = eZMimeType::findByURL( $file ); header( "Content-Type: {$mimeinfo['name']}" ); // Fixes problems with IE when opening a file directly header( "Pragma: " ); header( "Cache-Control: " ); + // Last-Modified header cannot be set, otherwise browser like FF will fail while resuming a paused download + // because it compares the value of Last-Modified headers between requests. + header( "Last-Modified: " ); /* Set cache time out to 10 minutes, this should be good enough to work around an IE bug */ header( "Expires: ". gmdate( 'D, d M Y H:i:s', time() + 600 ) . ' GMT' ); @@ -289,9 +291,14 @@ public static function downloadHeaders( $file, $isAttachedDownload = true, $over if ( $startOffset !== 0 ) { $endOffset = ( $length !== false ) ? ( $length + $startOffset - 1 ) : $fileSize - 1; + header( "Content-Length: " . ( $endOffset - $startOffset + 1 ) ); header( "Content-Range: bytes {$startOffset}-{$endOffset}/{$fileSize}" ); header( "HTTP/1.1 206 Partial Content" ); } + else + { + header( "Content-Length: $fileSize" ); + } header( 'Content-Transfer-Encoding: binary' ); header( 'Accept-Ranges: bytes' ); }