PHP Class Aerys\Root

Inheritance: implements SplObserver
Exibir arquivo Open project: amphp/aerys

Public Methods

Method Description
__construct ( string $root, Amp\File\Driver $filesystem = null )
__invoke ( aerys\Request $request, aerys\Response $response ) Respond to HTTP requests for filesystem resources
removeDotPathSegments ( string $path ) : string Normalize paths with relative dot segments in their path
setOption ( string $option, mixed $value ) Set a document root option
update ( Server $server ) : Amp\Promise Receive notifications from the server when it starts/stops

Private Methods

Method Description
assignCommonHeaders ( $fileInfo, aerys\Response $response )
checkPreconditions ( aerys\Request $request, integer $mtime, string $etag )
coalesceIndexPath ( string $dirPath ) : Generator
doNonRangeResponse ( $fileInfo, aerys\Response $response )
doRangeResponse ( $range, $fileInfo, aerys\Response $response )
fetchCachedStat ( string $reqPath, aerys\Request $request )
finalizeResponse ( aerys\Response $response, $fileInfo, $range = null ) : Generator
loadMimeFileTypes ( string $mimeFile )
lookup ( string $path ) : Generator
normalizeByteRanges ( integer $size, string $rawRanges )
respond ( $fileInfo, aerys\Request $request, aerys\Response $response )
respondWithLookup ( string $realPath, string $reqPath, aerys\Request $request, aerys\Response $response ) : Generator
selectMimeTypeFromPath ( string $path ) : string
sendMultiRange ( $handle, aerys\Response $response, $fileInfo, $range ) : Generator
sendNonRange ( Amp\File\Handle $handle, aerys\Response $response ) : Generator
sendSingleRange ( Amp\File\Handle $handle, aerys\Response $response, integer $startPos, integer $endPos ) : Generator
setAggressiveCacheMultiplier ( float $multiplier )
setBufferedFileMaxCount ( integer $count )
setBufferedFileMaxSize ( integer $bytes )
setCacheEntryMaxCount ( integer $count )
setCacheEntryTtl ( integer $seconds )
setDefaultMimeType ( string $mimeType )
setDefaultTextCharset ( string $charset )
setExpiresPeriod ( integer $seconds )
setIndexes ( $indexes )
setMimeTypes ( array $mimeTypes )
setUseAggressiveCacheHeaders ( boolean $bool )
setUseEtagInode ( boolean $useInode )
shouldBufferContent ( $fileInfo )

Method Details

__construct() public method

public __construct ( string $root, Amp\File\Driver $filesystem = null )
$root string Document root
$filesystem Amp\File\Driver Optional filesystem driver

__invoke() public method

Respond to HTTP requests for filesystem resources
public __invoke ( aerys\Request $request, aerys\Response $response )
$request aerys\Request
$response aerys\Response

removeDotPathSegments() public static method

This functionality is critical to avoid malicious URIs attempting to traverse the document root above the allowed base path.
public static removeDotPathSegments ( string $path ) : string
$path string
return string

setOption() public method

Set a document root option
public setOption ( string $option, mixed $value )
$option string The option key (case-insensitve)
$value mixed The option value to assign

update() public method

Receive notifications from the server when it starts/stops
public update ( Server $server ) : Amp\Promise
$server Server
return Amp\Promise