MediaWiki REL1_28
HTTPFileStreamer Class Reference

Functions related to the output of file content. More...

Collaboration diagram for HTTPFileStreamer:

Public Member Functions

 __construct ( $path, array $params=[])
 
 stream ( $headers=[], $sendErrors=true, $optHeaders=[], $flags=0)
 Stream a file to the browser, adding all the headings and fun stuff.
 

Static Public Member Functions

static parseRange ( $range, $size)
 Convert a Range header value to an absolute (start, end) range tuple.
 
static send404Message ( $fname, $flags=0)
 Send out a standard 404 message for a file.
 

Public Attributes

const STREAM_ALLOW_OB = 2
 
const STREAM_HEADLESS = 1
 

Static Protected Member Functions

static contentTypeFromPath ( $filename)
 Determine the file type of a file based on the path.
 
static resetOutputBuffers ()
 

Protected Attributes

callable $obResetFunc
 
string $path
 
callable $streamMimeFunc
 

Detailed Description

Functions related to the output of file content.

Since
1.28

Definition at line 28 of file HTTPFileStreamer.php.

Constructor & Destructor Documentation

◆ __construct()

HTTPFileStreamer::__construct (   $path,
array  $params = [] 
)
Parameters
string$pathLocal filesystem path to a file
array$paramsOptions map, which includes:
  • obResetFunc : alternative callback to clear the output buffer
  • streamMimeFunc : alternative method to determine the content type from the path

Definition at line 47 of file HTTPFileStreamer.php.

References $params, and $path.

Member Function Documentation

◆ contentTypeFromPath()

static HTTPFileStreamer::contentTypeFromPath (   $filename)
staticprotected

Determine the file type of a file based on the path.

Parameters
string$filenameStorage path or file system path
Returns
null|string

Definition at line 251 of file HTTPFileStreamer.php.

References $ext.

◆ parseRange()

static HTTPFileStreamer::parseRange (   $range,
  $size 
)
static

Convert a Range header value to an absolute (start, end) range tuple.

Parameters
string$rangeRange header value
integer$sizeFile size
Returns
array|string Returns error string on failure (start, end, length)
Since
1.24

Definition at line 208 of file HTTPFileStreamer.php.

References list.

Referenced by StreamFile\parseRange(), and stream().

◆ resetOutputBuffers()

static HTTPFileStreamer::resetOutputBuffers ( )
staticprotected

Definition at line 235 of file HTTPFileStreamer.php.

◆ send404Message()

static HTTPFileStreamer::send404Message (   $fname,
  $flags = 0 
)
static

Send out a standard 404 message for a file.

Parameters
string$fnameFull name and path of the file to stream
integer$flagsBitfield of STREAM_* constants
Since
1.24

Definition at line 184 of file HTTPFileStreamer.php.

References $flags, $fname, and HttpStatus\header().

Referenced by FileBackendStore\doStreamFile(), StreamFile\send404Message(), and stream().

◆ stream()

HTTPFileStreamer::stream (   $headers = [],
  $sendErrors = true,
  $optHeaders = [],
  $flags = 0 
)

Stream a file to the browser, adding all the headings and fun stuff.

Headers sent include: Content-type, Content-Length, Last-Modified, and Content-Disposition.

Parameters
array$headersAny additional headers to send if the file exists
bool$sendErrorsSend error messages if errors occur (like 404)
array$optHeadersHTTP request header map (e.g. "range") (use lowercase keys)
integer$flagsBitfield of STREAM_* constants
Exceptions
MWException
Returns
bool Success

Definition at line 69 of file HTTPFileStreamer.php.

References $flags, $header, $type, as, false, HttpStatus\header(), parseRange(), print, send404Message(), STREAM_HEADLESS, TS_RFC2822, and TS_UNIX.

Member Data Documentation

◆ $obResetFunc

callable HTTPFileStreamer::$obResetFunc
protected

Definition at line 32 of file HTTPFileStreamer.php.

◆ $path

string HTTPFileStreamer::$path
protected

Definition at line 30 of file HTTPFileStreamer.php.

Referenced by __construct().

◆ $streamMimeFunc

callable HTTPFileStreamer::$streamMimeFunc
protected

Definition at line 34 of file HTTPFileStreamer.php.

◆ STREAM_ALLOW_OB

const HTTPFileStreamer::STREAM_ALLOW_OB = 2

Definition at line 39 of file HTTPFileStreamer.php.

Referenced by FileBackendStore\doStreamFile().

◆ STREAM_HEADLESS

const HTTPFileStreamer::STREAM_HEADLESS = 1

Definition at line 37 of file HTTPFileStreamer.php.

Referenced by FileBackendStore\doStreamFile(), and stream().


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