MediaWiki  1.28.0
WebResponse Class Reference

Allow programs to request this object from WebRequest::response() and handle all outputting (or lack of outputting) via it. More...

Inheritance diagram for WebResponse:

Public Member Functions

 clearCookie ($name, $options=[])
 Unset a browser cookie. More...
 
 getHeader ($key)
 Get a response header. More...
 
 hasCookies ()
 Checks whether this request is performing cookie operations. More...
 
 header ($string, $replace=true, $http_response_code=null)
 Output an HTTP header, wrapper for PHP's header() More...
 
 headersSent ()
 Test if headers have been sent. More...
 
 setCookie ($name, $value, $expire=0, $options=[])
 Set the browser cookie. More...
 
 statusHeader ($code)
 Output an HTTP status code header. More...
 

Static Protected Attributes

static array $setCookies = []
 Used to record set cookies, because PHP's setcookie() will happily send an identical Set-Cookie to the client. More...
 

Detailed Description

Allow programs to request this object from WebRequest::response() and handle all outputting (or lack of outputting) via it.

Definition at line 28 of file WebResponse.php.

Member Function Documentation

WebResponse::clearCookie (   $name,
  $options = [] 
)

Unset a browser cookie.

This sets the cookie with an empty value and an expiry set to a time in the past, which will cause the browser to remove any cookie with the given name, domain and path from its cookie store. Options other than these (and prefix) have no effect.

Parameters
string$nameCookie name
array$optionsCookie options, see setCookie()
Since
1.27

Definition at line 169 of file WebResponse.php.

References $name, $options, and setCookie().

WebResponse::getHeader (   $key)

Get a response header.

Parameters
string$keyThe name of the header to get (case insensitive).
Returns
string|null The header value (if set); null otherwise.
Since
1.25

Definition at line 55 of file WebResponse.php.

References $header, $name, as, and list.

WebResponse::hasCookies ( )

Checks whether this request is performing cookie operations.

Returns
bool
Since
1.27

Definition at line 179 of file WebResponse.php.

WebResponse::header (   $string,
  $replace = true,
  $http_response_code = null 
)

Output an HTTP header, wrapper for PHP's header()

Parameters
string$stringHeader to output
bool$replaceReplace current similar header
null | int$http_response_codeForces the HTTP response code to the specified value.

Definition at line 41 of file WebResponse.php.

WebResponse::headersSent ( )

Test if headers have been sent.

Since
1.27
Returns
bool

Definition at line 79 of file WebResponse.php.

WebResponse::setCookie (   $name,
  $value,
  $expire = 0,
  $options = [] 
)

Set the browser cookie.

Parameters
string$nameThe name of the cookie.
string$valueThe value to be stored in the cookie.
int | null$expireUnix timestamp (in seconds) when the cookie should expire. 0 (the default) causes it to expire $wgCookieExpiration seconds from now. null causes it to be a session cookie.
array$optionsAssoc of additional cookie options: prefix: string, name prefix ($wgCookiePrefix) domain: string, cookie domain ($wgCookieDomain) path: string, cookie path ($wgCookiePath) secure: bool, secure attribute ($wgCookieSecure) httpOnly: bool, httpOnly attribute ($wgCookieHttpOnly)
Since
1.22 Replaced $prefix, $domain, and $forceSecure with $options

Definition at line 98 of file WebResponse.php.

References $name, $options, $value, $wgCookiePrefix, global, Hooks\run(), string, and wfDebugLog().

Referenced by clearCookie().

WebResponse::statusHeader (   $code)

Output an HTTP status code header.

Since
1.26
Parameters
int$codeStatus code

Definition at line 70 of file WebResponse.php.

References $code, and HttpStatus\header().

Member Data Documentation

array WebResponse::$setCookies = []
staticprotected

Used to record set cookies, because PHP's setcookie() will happily send an identical Set-Cookie to the client.

Definition at line 33 of file WebResponse.php.


The documentation for this class was generated from the following file: