Add Content-Length header to thumb.php redirects
[lhc/web/wiklou.git] / thumb.php
index 0d0a15e..03a3f35 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -213,6 +213,7 @@ function wfStreamThumb( array $params ) {
                        if ( count( $varyHeader ) ) {
                                $response->header( 'Vary: ' . implode( ', ', $varyHeader ) );
                        }
+                       $response->header( 'Content-Length: 0' );
                        return;
                }
 
@@ -298,8 +299,6 @@ function wfStreamThumb( array $params ) {
                $headers[] = 'Vary: ' . implode( ', ', $varyHeader );
        }
 
-       $stats = RequestContext::getMain()->getStats();
-
        // Stream the file if it exists already...
        $thumbPath = $img->getThumbPath( $thumbName );
        if ( $img->getRepo()->fileExists( $thumbPath ) ) {
@@ -310,7 +309,8 @@ function wfStreamThumb( array $params ) {
                if ( !$success ) {
                        wfThumbError( 500, 'Could not stream the file' );
                } else {
-                       $stats->timing( 'media.thumbnail.stream', $streamtime );
+                       RequestContext::getMain()->getStats()->timing( 'media.thumbnail.stream', $streamtime );
+                       wfDebugLog( 'thumbnailaccess', time() . ' ' . $thumbPath . ' ' . ob_get_length() . ' Streamed ' );
                }
                return;
        }
@@ -324,10 +324,8 @@ function wfStreamThumb( array $params ) {
                return;
        }
 
-       // Actually generate a new thumbnail
-       $starttime = microtime( true );
        list( $thumb, $errorMsg ) = wfGenerateThumbnail( $img, $params, $thumbName, $thumbPath );
-       $generatetime = microtime( true ) - $starttime;
+
        /** @var MediaTransformOutput|bool $thumb */
 
        // Check for thumbnail generation errors...
@@ -348,8 +346,6 @@ function wfStreamThumb( array $params ) {
        if ( $errorMsg !== false ) {
                wfThumbError( $errorCode, $errorMsg );
        } else {
-               $stats->timing( 'media.thumbnail.generate', $generatetime );
-
                // Stream the file if there were no errors
                $success = $thumb->streamFile( $headers );
                if ( !$success ) {