\OCPResponse

This class provides convenient functions to send the correct http response headers

Summary

Methods
Properties
Constants
enableCaching()
setLastModifiedHeader()
setContentDispositionHeader()
setContentLengthHeader()
disableCaching()
setETagHeader()
sendFile()
setExpiresHeader()
redirect()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

enableCaching()

enableCaching(integer  $cache_time = null) 

Enable response caching by sending correct HTTP headers

Parameters

integer $cache_time

time to cache the response

0 cache time in seconds 0 and <0 enable default browser caching null cache indefinitely

setLastModifiedHeader()

setLastModifiedHeader(string  $lastModified) 

Checks and set Last-Modified header, when the request matches sends a 'not modified' response

Parameters

string $lastModified

time when the response was last modified

setContentDispositionHeader()

setContentDispositionHeader(string  $filename, string  $type = 'attachment') 

Sets the content disposition header (with possible workarounds)

Parameters

string $filename

file name

string $type

disposition type, either 'attachment' or 'inline'

setContentLengthHeader()

setContentLengthHeader(string|integer|float  $length) 

Sets the content length header (with possible workarounds)

Parameters

string|integer|float $length

Length to be sent

disableCaching()

disableCaching() 

Disable browser caching

setETagHeader()

setETagHeader(string  $etag) 

Checks and set ETag header, when the request matches sends a 'not modified' response

Parameters

string $etag

token to use for modification check

sendFile()

sendFile(string  $filepath) 

Send file as response, checking and setting caching headers

Parameters

string $filepath

of file to send

setExpiresHeader()

setExpiresHeader(string|\DateTime  $expires) 

Set response expire time

Parameters

string|\DateTime $expires

date-time when the response expires string for DateInterval from now DateTime object when to expire response

redirect()

redirect(string  $location) 

Send redirect response

Parameters

string $location

to redirect to