Skip to content

Commit

Permalink
Fixed #019247: Pause/Resuming a download not working in firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickallaert committed Mar 22, 2012
1 parent 034db04 commit 236ebac
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/ezfile/classes/ezfile.php
Expand Up @@ -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' );
Expand All @@ -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' );
}
Expand Down

0 comments on commit 236ebac

Please sign in to comment.