Nextcloud PHP API (stable19)

DataDisplayResponse extends Response

Class DataDisplayResponse

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

Tags
since
8.1.0

Table of Contents

$data  : string
response data
$contentSecurityPolicy  : ContentSecurityPolicy|null
$cookies  : array
Cookies that will be need to be constructed as header
$ETag  : string
ETag
$featurePolicy  : FeaturePolicy
$headers  : array
Headers - defaults to ['Cache-Control' => 'no-cache, no-store, must-revalidate']
$lastModified  : DateTime
Last modified date
$status  : int
HTTP status code - defaults to STATUS OK
$throttled  : bool
$throttleMetadata  : array
__construct()  : mixed
addCookie()  : $this
Adds a new cookie to the response
addHeader()  : $this
Adds a new header to the response that will be called before the render function
cacheFor()  : $this
Caches the response
getContentSecurityPolicy()  : EmptyContentSecurityPolicy|null
Get the currently used Content-Security-Policy
getCookies()  : array
Returns the cookies
getData()  : string
Used to get the set parameters
getETag()  : string
Get the ETag
getFeaturePolicy()  : EmptyFeaturePolicy
getHeaders()  : array
Returns the set headers
getLastModified()  : DateTime
Get "last modified" date
getStatus()  : mixed
Get response status
getThrottleMetadata()  : array
Returns the throttle metadata, defaults to empty array
invalidateCookie()  : $this
Invalidates the specified cookie
invalidateCookies()  : $this
Invalidates the specified cookies
isThrottled()  : mixed
Whether the current response is throttled.
render()  : string
Outputs data. No processing is done.
setContentSecurityPolicy()  : $this
Set a Content-Security-Policy
setCookies()  : $this
Set the specified cookies
setData()  : DataDisplayResponse
Sets values in the data
setETag()  : Response
Set the ETag
setFeaturePolicy()  : self
setHeaders()  : $this
Set the headers
setLastModified()  : Response
Set "last modified" date
setStatus()  : Response
Set response status
throttle()  : mixed
Marks the response as to throttle. Will be throttled when the

Properties

$cookies

Cookies that will be need to be constructed as header

private array $cookies = []

$headers

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

private array $headers = ['Cache-Control' => 'no-cache, no-store, must-revalidate']

$lastModified

Last modified date

private DateTime $lastModified

$status

HTTP status code - defaults to STATUS OK

private int $status = OCPAppFrameworkHttp::STATUS_OK

$throttled

private bool $throttled = false

$throttleMetadata

private array $throttleMetadata = []

Methods

__construct()

public __construct([string $data = '' ][, int $statusCode = Http::STATUS_OK ][, array $headers = [] ]) : mixed
Parameters
$data : string = ''

the data to display

$statusCode : int = Http::STATUS_OK

the Http status code, defaults to 200

$headers : array = []

additional key value based headers

Tags
since
8.1.0
Return values
mixed

addCookie()

Adds a new cookie to the response

public addCookie(string $name, string $value[, DateTime|null $expireDate = null ][, string $sameSite = 'Lax' ]) : $this
Parameters
$name : string

The name of the cookie

$value : string

The value of the cookie

$expireDate : DateTime|null = null

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

$sameSite : string = 'Lax'

The samesite value of the cookie. Defaults to Lax. Other possibilities are Strict or None

Tags
since
8.0.0
Return values
$this

addHeader()

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

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

The name of the HTTP header

$value : string

The value, null will delete it

Tags
since
6.0.0
  • return value was added in 7.0.0
Return values
$this

cacheFor()

Caches the response

public cacheFor(int $cacheSeconds[, bool $public = false ]) : $this
Parameters
$cacheSeconds : int

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

$public : bool = false
Tags
since
6.0.0
  • return value was added in 7.0.0
Return values
$this

getCookies()

Returns the cookies

public getCookies() : array
Tags
since
8.0.0
Return values
array

getData()

Used to get the set parameters

public getData() : string
Tags
since
8.1.0
Return values
string

the data

getETag()

Get the ETag

public getETag() : string
Tags
since
6.0.0
Return values
string

the etag

getHeaders()

Returns the set headers

public getHeaders() : array
Tags
since
6.0.0
Return values
array

the headers

getLastModified()

Get "last modified" date

public getLastModified() : DateTime
Tags
since
6.0.0
Return values
DateTime

RFC2822 formatted last modified date

getStatus()

Get response status

public getStatus() : mixed
Tags
since
6.0.0
Return values
mixed

getThrottleMetadata()

Returns the throttle metadata, defaults to empty array

public getThrottleMetadata() : array
Tags
since
13.0.0
Return values
array

invalidateCookie()

Invalidates the specified cookie

public invalidateCookie(string $name) : $this
Parameters
$name : string
Tags
since
8.0.0
Return values
$this

invalidateCookies()

Invalidates the specified cookies

public invalidateCookies(array $cookieNames) : $this
Parameters
$cookieNames : array

array('foo', 'bar')

Tags
since
8.0.0
Return values
$this

isThrottled()

Whether the current response is throttled.

public isThrottled() : mixed
Tags
since
12.0.0
Return values
mixed

render()

Outputs data. No processing is done.

public render() : string
Tags
since
8.1.0
Return values
string

setCookies()

Set the specified cookies

public setCookies(array $cookies) : $this
Parameters
$cookies : array

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

Tags
since
8.0.0
Return values
$this

setETag()

Set the ETag

public setETag(string $ETag) : Response
Parameters
$ETag : string
Tags
since
6.0.0
  • return value was added in 7.0.0
Return values
Response

Reference to this object

setHeaders()

Set the headers

public setHeaders(array $headers) : $this
Parameters
$headers : array

value header pairs

Tags
since
8.0.0
Return values
$this

setLastModified()

Set "last modified" date

public setLastModified(DateTime $lastModified) : Response
Parameters
$lastModified : DateTime
Tags
since
6.0.0
  • return value was added in 7.0.0
Return values
Response

Reference to this object

setStatus()

Set response status

public setStatus(int $status) : Response
Parameters
$status : int

a HTTP status code, see also the STATUS constants

Tags
since
6.0.0
  • return value was added in 7.0.0
Return values
Response

Reference to this object

throttle()

Marks the response as to throttle. Will be throttled when the

public throttle([array $metadata = [] ]) : mixed
Parameters
$metadata : array = []
Tags
BruteForceProtection

annotation is added.

since
12.0.0
Return values
mixed

Search results