MediaWiki master
MediaWiki\Rest\ConditionalHeaderUtil Class Reference

Public Member Functions

 __construct ()
 
 applyResponseHeaders (ResponseInterface $response)
 Set Last-Modified and ETag headers in the response according to the cached values set by setValidators(), which are also used for precondition checks.
 
 checkPreconditions (RequestInterface $request)
 Check conditional request headers in the order required by RFC 7232 section 6.
 
 setValidators ( $eTag, $lastModified, $hasRepresentation=null)
 Initialize the object with information about the requested resource.
 
 setVarnishETagHack ( $hack)
 If the Varnish ETag hack is disabled by calling this method, strong ETag comparison will follow RFC 7232, rejecting all weak ETags for If-Match comparison.
 

Detailed Description

Definition at line 10 of file ConditionalHeaderUtil.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Rest\ConditionalHeaderUtil::__construct ( )

Definition at line 24 of file ConditionalHeaderUtil.php.

Member Function Documentation

◆ applyResponseHeaders()

MediaWiki\Rest\ConditionalHeaderUtil::applyResponseHeaders ( ResponseInterface $response)

Set Last-Modified and ETag headers in the response according to the cached values set by setValidators(), which are also used for precondition checks.

If the headers are already present in the response, the existing headers take precedence.

Definition at line 193 of file ConditionalHeaderUtil.php.

References MediaWiki\Rest\ResponseInterface\getStatusCode(), MediaWiki\Rest\ResponseInterface\hasHeader(), and MediaWiki\Rest\ResponseInterface\setHeader().

◆ checkPreconditions()

MediaWiki\Rest\ConditionalHeaderUtil::checkPreconditions ( RequestInterface $request)

Check conditional request headers in the order required by RFC 7232 section 6.

Parameters
RequestInterface$request
Returns
int|null The status code to immediately return, or null to continue processing the request.

Definition at line 134 of file ConditionalHeaderUtil.php.

References MediaWiki\Rest\RequestInterface\getHeader(), MediaWiki\Rest\RequestInterface\getMethod(), and MediaWiki\Rest\RequestInterface\hasHeader().

◆ setValidators()

MediaWiki\Rest\ConditionalHeaderUtil::setValidators ( $eTag,
$lastModified,
$hasRepresentation = null )

Initialize the object with information about the requested resource.

Parameters
callable | string | null$eTagThe entity-tag (including quotes), or null if it is unknown. Can also be provided as a callback for later evaluation.
callable | string | int | null$lastModifiedThe Last-Modified date in a format accepted by ConvertibleTimestamp, or null if it is unknown. Can also be provided as a callback for later evaluation.
callable | bool | null$hasRepresentationWhether the server can serve a representation of the target resource. This should be true if the resource exists, and false if it does not exist. It is used for wildcard validators – the intended use case is to abort a PUT if the resource does (or does not) exist. If null is passed, we assume that the resource exists if an ETag or last-modified data was specified for it. Can also be provided as a callback for later evaluation.

Definition at line 44 of file ConditionalHeaderUtil.php.

Referenced by MediaWiki\Rest\Handler\getConditionalHeaderUtil().

◆ setVarnishETagHack()

MediaWiki\Rest\ConditionalHeaderUtil::setVarnishETagHack ( $hack)

If the Varnish ETag hack is disabled by calling this method, strong ETag comparison will follow RFC 7232, rejecting all weak ETags for If-Match comparison.

Parameters
bool$hack

Definition at line 61 of file ConditionalHeaderUtil.php.


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