Functions related to the output of file content.
More...
|
| __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 | parseRange ( $range, $size) |
| Convert a Range header value to an absolute (start, end) range tuple.
|
|
static | preprocessHeaders ( $headers) |
| Takes HTTP headers in a name => value format and converts them to the weird format expected by stream().
|
|
static | send404Message ( $fname, $flags=0) |
| Send out a standard 404 message for a file.
|
|
Functions related to the output of file content.
- Since
- 1.28
Definition at line 31 of file HTTPFileStreamer.php.
◆ __construct()
HTTPFileStreamer::__construct |
( |
| $path, |
|
|
array | $params = [] ) |
- Parameters
-
string | $path | Local filesystem path to a file |
array | $params | Options 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 71 of file HTTPFileStreamer.php.
References $path.
◆ contentTypeFromPath()
static HTTPFileStreamer::contentTypeFromPath |
( |
| $filename | ) |
|
|
staticprotected |
Determine the file type of a file based on the path.
- Parameters
-
string | $filename | Storage path or file system path |
- Returns
- null|string
Definition at line 270 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 | $range | Range header value |
int | $size | File size |
- Returns
- array|string Returns error string on failure (start, end, length)
- Since
- 1.24
Definition at line 227 of file HTTPFileStreamer.php.
Referenced by StreamFile\parseRange(), and stream().
◆ preprocessHeaders()
static HTTPFileStreamer::preprocessHeaders |
( |
| $headers | ) |
|
|
static |
Takes HTTP headers in a name => value format and converts them to the weird format expected by stream().
- Parameters
-
- Returns
- array[] [ $headers, $optHeaders ]
- Since
- 1.34
Definition at line 51 of file HTTPFileStreamer.php.
References $header.
◆ resetOutputBuffers()
static HTTPFileStreamer::resetOutputBuffers |
( |
| ) |
|
|
staticprotected |
◆ send404Message()
static HTTPFileStreamer::send404Message |
( |
| $fname, |
|
|
| $flags = 0 ) |
|
static |
◆ 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 | $headers | Any additional headers to send if the file exists |
bool | $sendErrors | Send error messages if errors occur (like 404) |
array | $optHeaders | HTTP request header map (e.g. "range") (use lowercase keys) |
int | $flags | Bitfield of STREAM_* constants |
- Returns
- bool Success
Definition at line 88 of file HTTPFileStreamer.php.
References $header, $type, parseRange(), print, send404Message(), and STREAM_HEADLESS.
◆ $obResetFunc
callable HTTPFileStreamer::$obResetFunc |
|
protected |
◆ $path
string HTTPFileStreamer::$path |
|
protected |
◆ $streamMimeFunc
callable HTTPFileStreamer::$streamMimeFunc |
|
protected |
◆ STREAM_ALLOW_OB
const HTTPFileStreamer::STREAM_ALLOW_OB = 2 |
◆ STREAM_HEADLESS
const HTTPFileStreamer::STREAM_HEADLESS = 1 |
The documentation for this class was generated from the following file: