From 6b5e2f5f0b96f05e66789a9849e455db4df35cf0 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 3 Nov 2007 02:38:40 +0000 Subject: [PATCH] Send Cache-Control: private and Vary headers in img_auth.php. --- img_auth.php | 9 +++++---- includes/StreamFile.php | 6 +++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/img_auth.php b/img_auth.php index 2e8f6240f7..bb419b39aa 100644 --- a/img_auth.php +++ b/img_auth.php @@ -66,7 +66,7 @@ if( is_dir( $filename ) ) { // Stream the requested file wfDebugLog( 'img_auth', "Streaming `{$filename}`" ); -wfStreamFile( $filename ); +wfStreamFile( $filename, array( 'Cache-Control: private', 'Vary: Cookie' ) ); wfLogProfilingData(); /** @@ -75,15 +75,16 @@ wfLogProfilingData(); */ function wfForbidden() { header( 'HTTP/1.0 403 Forbidden' ); + header( 'Vary: Cookie' ); header( 'Content-Type: text/html; charset=utf-8' ); - echo <<

Access Denied

You need to log in to access files on this server.

-END; +ENDS; wfLogProfilingData(); exit(); -} \ No newline at end of file +} diff --git a/includes/StreamFile.php b/includes/StreamFile.php index 8ecaa4f006..2dbbe6dee3 100644 --- a/includes/StreamFile.php +++ b/includes/StreamFile.php @@ -2,7 +2,7 @@ /** */ /** */ -function wfStreamFile( $fname ) { +function wfStreamFile( $fname, $headers = array() ) { $stat = @stat( $fname ); if ( !$stat ) { header( 'HTTP/1.0 404 Not Found' ); @@ -34,6 +34,10 @@ function wfStreamFile( $fname ) { global $wgContLanguageCode; header( "Content-Disposition: inline;filename*=utf-8'$wgContLanguageCode'" . urlencode( basename( $fname ) ) ); + foreach ( $headers as $header ) { + header( $header ); + } + if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { $modsince = preg_replace( '/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); $sinceTime = strtotime( $modsince ); -- 2.20.1