PHP Class Piwik\ProxyHttp

.. Used to server piwik.js and the merged+minified CSS and JS files
Mostra file Open project: piwik/piwik Class Usage Examples

Public Methods

Method Description
isHttps ( ) : boolean Returns true if the current request appears to be a secure HTTPS connection
isPhpOutputCompressed ( ) : boolean Test if php output is compressed
overrideCacheControlHeaders ( string $override = null ) Workaround IE bug when downloading certain document types over SSL and cache control headers are present, e.g.,
serverStaticFile ( string $file, string $contentType, $expireFarFutureDays = 100, integer | false $byteStart = false, integer | false $byteEnd = false, string | false $filename = false ) Serve static files through php proxy.

Private Methods

Method Description
canCompressInPhp ( )
compressFile ( $fileToCompress, $compressedFilePath, $compressionEncoding, $byteStart, $byteEnd )
getCompressionEncodingAcceptedByClient ( )
getExpiresHeaderForFutureDay ( $expireFarFutureDays ) Returns a formatted Expires HTTP header for a certain number of days in the future. The result can be used in a call to header().
shouldCompressFile ( $fileToCompress, $compressedFilePath )

Method Details

isHttps() public static method

Returns true if the current request appears to be a secure HTTPS connection
public static isHttps ( ) : boolean
return boolean

isPhpOutputCompressed() public static method

Test if php output is compressed
public static isPhpOutputCompressed ( ) : boolean
return boolean True if php output is (or suspected/likely) to be compressed

overrideCacheControlHeaders() public static method

Cache-Control: no-cache Cache-Control: no-store,max-age=0,must-revalidate Pragma: no-cache
See also: http://support.microsoft.com/kb/316431/
See also: RFC2616
public static overrideCacheControlHeaders ( string $override = null )
$override string One of "public", "private", "no-cache", or "no-store". (optional)

serverStaticFile() public static method

It performs the following actions: - Checks the file is readable or returns "HTTP/1.0 404 Not Found" - Returns "HTTP/1.1 304 Not Modified" after comparing the HTTP_IF_MODIFIED_SINCE with the modification date of the static file - Will try to compress the static file according to HTTP_ACCEPT_ENCODING. Compressed files are store in the /tmp directory. If compressing extensions are not available, a manually gzip compressed file can be provided in the /tmp directory. It has to bear the same name with an added .gz extension. Using manually compressed static files requires you to manually update the compressed file when the static file is updated. - Overrides server cache control config to allow caching - Sends Very Accept-Encoding to tell proxies to store different version of the static file according to users encoding capacities. Warning: Compressed filed are stored in the /tmp directory. If this method is used with two files bearing the same name but located in different locations, there is a risk of conflict. One file could be served with the content of the other. A future upgrade of this method would be to recreate the directory structure of the static file within a /tmp/compressed-static-files directory.
public static serverStaticFile ( string $file, string $contentType, $expireFarFutureDays = 100, integer | false $byteStart = false, integer | false $byteEnd = false, string | false $filename = false )
$file string The location of the static file to serve
$contentType string The content type of the static file.
$byteStart integer | false The starting byte in the file to serve. If false, the data from the beginning of the file will be served.
$byteEnd integer | false The ending byte in the file to serve. If false, the data from $byteStart to the end of the file will be served.
$filename string | false By default the filename of $file is reused as Content-Disposition. If the file should be sent as a different filename to the client you can specify a custom filename here.