MediaWiki REL1_37
MediaWiki\OutputHandler Class Reference

Static Public Member Functions

static handle ( $s, $phase)
 Standard output handler for use with ob_start.
 

Static Private Member Functions

static emitContentLength ( $length)
 Set the Content-Length header if possible.
 
static findUriExtension ()
 Get the "file extension" that some client apps will estimate from the currently-requested URL.
 
static handleGzip ( $s)
 Handler that compresses data with gzip if allowed by the Accept header.
 
static mangleFlashPolicy ( $s)
 Mangle flash policy tags which open up the site to XSS attacks.
 

Detailed Description

Since
1.31

Definition at line 30 of file OutputHandler.php.

Member Function Documentation

◆ emitContentLength()

static MediaWiki\OutputHandler::emitContentLength (   $length)
staticprivate

Set the Content-Length header if possible.

This sets Content-Length for the following cases:

  • When the response body is meaningful (HTTP 200/404).
  • On any HTTP 1.0 request response. This improves cooperation with certain CDNs.

This assumes that HEAD requests are processed as GET requests by MediaWiki and that the webserver is tasked with stripping out the body.

Setting Content-Length can prevent clients from getting stuck waiting on PHP to finish while deferred updates are running.

Parameters
int$length

Definition at line 212 of file OutputHandler.php.

References wfDebug().

◆ findUriExtension()

static MediaWiki\OutputHandler::findUriExtension ( )
staticprivate

Get the "file extension" that some client apps will estimate from the currently-requested URL.

This isn't a WebRequest method, because we need it before the class loads.

Todo:
As of 2018, this actually runs after autoloader in Setup.php, so WebRequest seems like a good place for this.
Returns
string

Definition at line 104 of file OutputHandler.php.

References $path.

◆ handle()

static MediaWiki\OutputHandler::handle (   $s,
  $phase 
)
static

Standard output handler for use with ob_start.

Output buffers using this method should only be started from MW_SETUP_CALLBACK, and only if there are no parent output buffers.

Parameters
string$sWeb response output
int$phaseFlags indicating the reason for the call
Returns
string

Definition at line 41 of file OutputHandler.php.

References $s, $wgDisableOutputCompression, $wgMangleFlashPolicy, and MW_ENTRY_POINT.

◆ handleGzip()

static MediaWiki\OutputHandler::handleGzip (   $s)
staticprivate

Handler that compresses data with gzip if allowed by the Accept header.

Unlike ob_gzhandler, it works for HEAD requests too. This assumes that the application processes them as normal GET request and that the webserver is tasked with stripping out the response body before sending the response the client.

Parameters
string$sWeb response output
Returns
string

Definition at line 134 of file OutputHandler.php.

References $ext, $header, $s, wfClientAcceptsGzip(), and wfDebug().

◆ mangleFlashPolicy()

static MediaWiki\OutputHandler::mangleFlashPolicy (   $s)
staticprivate

Mangle flash policy tags which open up the site to XSS attacks.

Parameters
string$sWeb response output
Returns
string

Definition at line 188 of file OutputHandler.php.

References $s.


The documentation for this class was generated from the following file: