MediaWiki master
MediaWiki\Request\FauxResponse Class Reference

Inherits MediaWiki\Request\WebResponse.

Collaboration diagram for MediaWiki\Request\FauxResponse:

Public Member Functions

 getCookie ( $name)
 
 getCookieData ( $name)
 
 getCookies ()
 
 getHeader ( $key)
 
 getHeaders ()
 
 getStatusCode ()
 Get the HTTP response code, null if not set.
 
 hasCookies ()
 Checks whether this request is performing cookie operations.
Returns
bool
Since
1.27

 
 header ( $string, $replace=true, $http_response_code=null)
 Stores a HTTP header.
 
 headersSent ()
 Test if headers have been sent.
Since
1.27
Returns
bool

 
 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)
  • raw: bool, true to suppress encoding of the value
  • sameSite: string|null, SameSite attribute. May be "strict", "lax", "none", or null or "" for no attribute. (default absent)
  • sameSiteLegacy: bool|null, this option is now ignored
Since
1.22 Replaced $prefix, $domain, and $forceSecure with $options

 
 setCookieConfig (Config $cookieConfig)
 
 statusHeader ( $code)
 
- Public Member Functions inherited from MediaWiki\Request\WebResponse
 clearCookie ( $name, $options=[])
 Unset a browser cookie.
 
 disableForPostSend ()
 Disable setters for post-send processing.
 

Additional Inherited Members

- Static Public Member Functions inherited from MediaWiki\Request\WebResponse
static resetCookieCache ()
 
- Protected Member Functions inherited from MediaWiki\Request\WebResponse
 actuallySetCookie (string $func, string $prefixedName, string $value, array $setOptions)
 
- Protected Attributes inherited from MediaWiki\Request\WebResponse
bool $disableForPostSend = false
 Used to disable setters before running jobs post-request (T191537)
 
- Static Protected Attributes inherited from MediaWiki\Request\WebResponse
static array $setCookies = []
 Used to record set cookies, because PHP's setcookie() will happily send an identical Set-Cookie to the client.
 

Detailed Description

Definition at line 20 of file FauxResponse.php.

Member Function Documentation

◆ getCookie()

MediaWiki\Request\FauxResponse::getCookie ( $name)
Parameters
string$name
Returns
string|null

Definition at line 155 of file FauxResponse.php.

◆ getCookieData()

MediaWiki\Request\FauxResponse::getCookieData ( $name)
Parameters
string$name
Returns
array{value:string,expire:int,domain:string,path:string,secure:bool,httpOnly:bool}|null

Definition at line 166 of file FauxResponse.php.

◆ getCookies()

MediaWiki\Request\FauxResponse::getCookies ( )
Returns
array[]

Definition at line 173 of file FauxResponse.php.

◆ getHeader()

MediaWiki\Request\FauxResponse::getHeader ( $key)
Parameters
string$keyThe name of the header to get (case insensitive).
Returns
string|null The header value (if set); null otherwise.

Reimplemented from MediaWiki\Request\WebResponse.

Definition at line 77 of file FauxResponse.php.

◆ getHeaders()

MediaWiki\Request\FauxResponse::getHeaders ( )
Returns
string[] All set headers

Definition at line 84 of file FauxResponse.php.

◆ getStatusCode()

MediaWiki\Request\FauxResponse::getStatusCode ( )

Get the HTTP response code, null if not set.

Returns
int|null

Reimplemented from MediaWiki\Request\WebResponse.

Definition at line 93 of file FauxResponse.php.

◆ hasCookies()

MediaWiki\Request\FauxResponse::hasCookies ( )

Checks whether this request is performing cookie operations.

Returns
bool
Since
1.27

Reimplemented from MediaWiki\Request\WebResponse.

Definition at line 180 of file FauxResponse.php.

◆ header()

MediaWiki\Request\FauxResponse::header ( $string,
$replace = true,
$http_response_code = null )

Stores a HTTP header.

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

Reimplemented from MediaWiki\Request\WebResponse.

Definition at line 37 of file FauxResponse.php.

References MediaWiki\Request\WebResponse\disableForPostSend().

◆ headersSent()

MediaWiki\Request\FauxResponse::headersSent ( )

Test if headers have been sent.

Since
1.27
Returns
bool

Reimplemented from MediaWiki\Request\WebResponse.

Definition at line 69 of file FauxResponse.php.

◆ setCookie()

MediaWiki\Request\FauxResponse::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)
  • raw: bool, true to suppress encoding of the value
  • sameSite: string|null, SameSite attribute. May be "strict", "lax", "none", or null or "" for no attribute. (default absent)
  • sameSiteLegacy: bool|null, this option is now ignored
Since
1.22 Replaced $prefix, $domain, and $forceSecure with $options

The sameSite $options value is ignored (not implemented in this subclass).

Reimplemented from MediaWiki\Request\WebResponse.

Definition at line 113 of file FauxResponse.php.

References MediaWiki\Config\Config\get().

◆ setCookieConfig()

MediaWiki\Request\FauxResponse::setCookieConfig ( Config $cookieConfig)

Definition at line 104 of file FauxResponse.php.

◆ statusHeader()

MediaWiki\Request\FauxResponse::statusHeader ( $code)
Since
1.26
Parameters
int$codeStatus code

Reimplemented from MediaWiki\Request\WebResponse.

Definition at line 64 of file FauxResponse.php.


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