\OCP\AppFramework\HttpDataDownloadResponse

Class DataDownloadResponse

It handles headers, HTTP status code, last modified and ETag.

Summary

Methods
Properties
Constants
__construct()
cacheFor()
addCookie()
setCookies()
invalidateCookie()
invalidateCookies()
getCookies()
addHeader()
setHeaders()
getHeaders()
render()
setStatus()
setContentSecurityPolicy()
getContentSecurityPolicy()
getStatus()
getETag()
getLastModified()
setETag()
setLastModified()
setData()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$filename
$contentType
$headers
$cookies
$status
$lastModified
$ETag
$contentSecurityPolicy
$data
N/A

Properties

$filename

$filename : 

Type

$contentType

$contentType : 

Type

$headers

$headers : array

Headers - defaults to ['Cache-Control' => 'no-cache, must-revalidate']

Type

array

$cookies

$cookies : array

Cookies that will be need to be constructed as header

Type

array

$status

$status : integer

HTTP status code - defaults to STATUS OK

Type

integer

$lastModified

$lastModified : \DateTime

Last modified date

Type

\DateTime

$ETag

$ETag : string

ETag

Type

string

$data

$data : string

Type

string

Methods

__construct()

__construct(string  $data, string  $filename, string  $contentType) 

Creates a response that prompts the user to download the text

Parameters

string $data

text to be downloaded

string $filename

the name that the downloaded file should have

string $contentType

the mimetype that the downloaded file should have

cacheFor()

cacheFor(integer  $cacheSeconds) : $this

Caches the response

Parameters

integer $cacheSeconds

the amount of seconds that should be cached if 0 then caching will be disabled

Returns

$this

addCookie()

addCookie(string  $name, string  $value, \DateTime|null  $expireDate = null) : $this

Adds a new cookie to the response

Parameters

string $name

The name of the cookie

string $value

The value of the cookie

\DateTime|null $expireDate

Date on that the cookie should expire, if set to null cookie will be considered as session cookie.

Returns

$this

setCookies()

setCookies(array  $cookies) : $this

Set the specified cookies

Parameters

array $cookies

array('foo' => array('value' => 'bar', 'expire' => null))

Returns

$this

invalidateCookie()

invalidateCookie(string  $name) : $this

Invalidates the specified cookie

Parameters

string $name

Returns

$this

invalidateCookies()

invalidateCookies(array  $cookieNames) : $this

Invalidates the specified cookies

Parameters

array $cookieNames

array('foo', 'bar')

Returns

$this

getCookies()

getCookies() : array

Returns the cookies

Returns

array

addHeader()

addHeader(string  $name, string  $value) : $this

Adds a new header to the response that will be called before the render function

Parameters

string $name

The name of the HTTP header

string $value

The value, null will delete it

Returns

$this

setHeaders()

setHeaders(array  $headers) : $this

Set the headers

Parameters

array $headers

value header pairs

Returns

$this

getHeaders()

getHeaders() : array

Returns the set headers

Returns

array —

the headers

render()

render() : string

Returns

string

setStatus()

setStatus(integer  $status) : \OCP\AppFramework\Http\Response

Set response status

Parameters

integer $status

a HTTP status code, see also the STATUS constants

Returns

\OCP\AppFramework\Http\Response

Reference to this object

setContentSecurityPolicy()

setContentSecurityPolicy(\OCP\AppFramework\Http\ContentSecurityPolicy  $csp) : $this

Set a Content-Security-Policy

Parameters

\OCP\AppFramework\Http\ContentSecurityPolicy $csp

Policy to set for the response object

Returns

$this

getContentSecurityPolicy()

getContentSecurityPolicy() : \OCP\AppFramework\Http\ContentSecurityPolicy|null

Get the currently used Content-Security-Policy

Returns

\OCP\AppFramework\Http\ContentSecurityPolicy|null —

Used Content-Security-Policy or null if none specified.

getStatus()

getStatus() 

Get response status

getETag()

getETag() : string

Get the ETag

Returns

string —

the etag

getLastModified()

getLastModified() : \DateTime

Get "last modified" date

Returns

\DateTime —

RFC2822 formatted last modified date

setETag()

setETag(string  $ETag) : \OCP\AppFramework\Http\Response

Set the ETag

Parameters

string $ETag

Returns

\OCP\AppFramework\Http\Response

Reference to this object

setLastModified()

setLastModified(\DateTime  $lastModified) : \OCP\AppFramework\Http\Response

Set "last modified" date

Parameters

\DateTime $lastModified

Returns

\OCP\AppFramework\Http\Response

Reference to this object

setData()

setData(string  $data) 

Parameters

string $data