Nextcloud PHP API (master)

DataDownloadResponse extends DownloadResponse
in package

Class DataDownloadResponse

Tags
since
8.0.0
template

S of int

template

C of string

template

H of array<string, mixed>

template-extends

DownloadResponse<int, string, array<string, mixed>>

Table of Contents

Properties

$contentSecurityPolicy  : ContentSecurityPolicy|null
$cookies  : array<string|int, mixed>
Cookies that will be need to be constructed as header
$data  : string
$ETag  : string
ETag
$featurePolicy  : FeaturePolicy
$headers  : H
Headers
$lastModified  : DateTime
Last modified date
$status  : S
HTTP status code - defaults to STATUS OK
$throttled  : bool
$throttleMetadata  : array<string|int, mixed>

Methods

__construct()  : mixed
Creates a response that prompts the user to download the text
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<string|int, mixed>
Returns the cookies
getETag()  : string
Get the ETag
getFeaturePolicy()  : EmptyFeaturePolicy
getHeaders()  : mixed
Returns the set headers
getLastModified()  : DateTime
Get "last modified" date
getStatus()  : S
Get response status
getThrottleMetadata()  : array<string|int, mixed>
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
By default renders no output
setContentSecurityPolicy()  : $this
Set a Content-Security-Policy
setCookies()  : $this
Set the specified cookies
setData()  : mixed
setETag()  : Response
Set the ETag
setFeaturePolicy()  : self
setHeaders()  : static
Set the headers
setLastModified()  : Response
Set "last modified" date
setStatus()  : static
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<string|int, mixed> $cookies = []

$lastModified

Last modified date

private DateTime $lastModified

$status

HTTP status code - defaults to STATUS OK

private S $status

$throttled

private bool $throttled = false

$throttleMetadata

private array<string|int, mixed> $throttleMetadata = []

Methods

__construct()

Creates a response that prompts the user to download the text

public __construct(string $data, string $filename, C $contentType[, S $status = Http::STATUS_OK ][, H $headers = [] ]) : mixed
Parameters
$data : string

text to be downloaded

$filename : string

the name that the downloaded file should have

$contentType : C

the mimetype that the downloaded file should have

$status : S = Http::STATUS_OK
$headers : H = []
Tags
since
8.0.0

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 ][, bool $immutable = false ]) : $this
Parameters
$cacheSeconds : int

amount of seconds the response is fresh, 0 to disable cache.

$public : bool = false

whether the page should be cached by public proxy. Usually should be false, unless this is a static resources.

$immutable : bool = false

whether browser should treat the resource as immutable and not ask the server for each page load if the resource changed.

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

getCookies()

Returns the cookies

public getCookies() : array<string|int, mixed>
Tags
since
8.0.0
Return values
array<string|int, mixed>

getETag()

Get the ETag

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

the etag

getHeaders()

Returns the set headers

public getHeaders() : mixed
Tags
@return

array{X-Request-Id: string, Cache-Control: string, Content-Security-Policy: string, Feature-Policy: string, X-Robots-Tag: string, Last-Modified?: string, ETag?: string, ...H} the headers

since
6.0.0

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() : S
Tags
since
6.0.0
Return values
S

getThrottleMetadata()

Returns the throttle metadata, defaults to empty array

public getThrottleMetadata() : array<string|int, mixed>
Tags
since
13.0.0
Return values
array<string|int, mixed>

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<string|int, mixed> $cookieNames) : $this
Parameters
$cookieNames : array<string|int, mixed>

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

render()

By default renders no output

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

setCookies()

Set the specified cookies

public setCookies(array<string|int, mixed> $cookies) : $this
Parameters
$cookies : array<string|int, mixed>

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

Tags
since
8.0.0
Return values
$this

setData()

public setData(string $data) : mixed
Parameters
$data : string
Tags
since
8.0.0

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(NewH $headers) : static
Parameters
$headers : NewH

value header pairs

Tags
template

NewH as array<string, mixed>

psalm-this-out

static<S, NewH>

since
8.0.0
Return values
static

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(NewS $status) : static
Parameters
$status : NewS

a HTTP status code, see also the STATUS constants

Tags
template

NewS as int

psalm-this-out

static<NewS, H>

since
6.0.0
  • return value was added in 7.0.0
Return values
static

throttle()

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

public throttle([array<string|int, mixed> $metadata = [] ]) : mixed
Parameters
$metadata : array<string|int, mixed> = []
Tags
BruteForceProtection

annotation is added.

since
12.0.0

        
On this page

Search results