- if ( $isHTML ) {
- $s = wfHtmlValidationHandler( $s );
- }
- }
- if ( !$wgDisableOutputCompression && !ini_get( 'zlib.output_compression' ) ) {
- if ( !defined( 'MW_NO_OUTPUT_COMPRESSION' ) ) {
- $s = wfGzipHandler( $s );
- }
- if ( !ini_get( 'output_handler' ) ) {
- wfDoContentLength( strlen( $s ) );
- }
- }
- return $s;
-}
-
-/**
- * Get the "file extension" that some client apps will estimate from
- * the currently-requested URL.
- * This isn't on WebRequest because we need it when things aren't initialized
- * @private
- *
- * @return string
- */
-function wfRequestExtension() {
- /// @todo FIXME: this sort of dupes some code in WebRequest::getRequestUrl()
- if ( isset( $_SERVER['REQUEST_URI'] ) ) {
- // Strip the query string...
- list( $path ) = explode( '?', $_SERVER['REQUEST_URI'], 2 );
- } elseif ( isset( $_SERVER['SCRIPT_NAME'] ) ) {
- // Probably IIS. QUERY_STRING appears separately.
- $path = $_SERVER['SCRIPT_NAME'];
- } else {
- // Can't get the path from the server? :(
- return '';
- }
-
- $period = strrpos( $path, '.' );
- if ( $period !== false ) {
- return strtolower( substr( $path, $period ) );
- }
- return '';
-}
-
-/**
- * Handler that compresses data with gzip if allowed by the Accept header.
- * Unlike ob_gzhandler, it works for HEAD requests too.
- *
- * @param string $s
- *
- * @return string
- */
-function wfGzipHandler( $s ) {
- if ( !function_exists( 'gzencode' ) ) {
- wfDebug( __FUNCTION__ . "() skipping compression (gzencode unavailable)\n" );
- return $s;
- }
- if ( headers_sent() ) {
- wfDebug( __FUNCTION__ . "() skipping compression (headers already sent)\n" );