MediaWiki master
MediaWiki\Rest\HeaderParser\IfNoneMatch Class Reference

A class to assist with the parsing of If-None-Match, If-Match and ETag headers. More...

Inherits MediaWiki\Rest\HeaderParser\HeaderParserBase.

Collaboration diagram for MediaWiki\Rest\HeaderParser\IfNoneMatch:

Public Member Functions

 getLastError ()
 Get the last parse error message, or null if there was none.
 
 parseETag ( $eTag)
 Parse an entity-tag such as might be found in an ETag response header.
 
 parseHeaderList ( $headerList)
 Parse an If-None-Match or If-Match header list as returned by RequestInterface::getHeader().
 

Additional Inherited Members

- Protected Member Functions inherited from MediaWiki\Rest\HeaderParser\HeaderParserBase
 assertEnd ()
 If the position is not at the end of the input string, raise an error, complaining of trailing characters.
 
 consumeFixedDigits ( $numDigits)
 Consume a specified number of digits, or throw an exception.
 
 consumeString ( $s)
 Consume a specified string, or throw an exception.
 
 error ( $message)
 Throw an exception to indicate a parse error.
 
 setInput ( $input)
 Set the input, and derived convenience properties.
 
 skipWhitespace ()
 Skip whitespace at the input position (OWS)
 
- Protected Attributes inherited from MediaWiki\Rest\HeaderParser\HeaderParserBase
string $input
 The input string being processed.
 
int $inputLength
 The length of $input.
 
int $pos
 The position within $input.
 

Detailed Description

A class to assist with the parsing of If-None-Match, If-Match and ETag headers.

Definition at line 8 of file IfNoneMatch.php.

Member Function Documentation

◆ getLastError()

MediaWiki\Rest\HeaderParser\IfNoneMatch::getLastError ( )

Get the last parse error message, or null if there was none.

Returns
string|null

Definition at line 88 of file IfNoneMatch.php.

◆ parseETag()

MediaWiki\Rest\HeaderParser\IfNoneMatch::parseETag ( $eTag)

Parse an entity-tag such as might be found in an ETag response header.

The result is an associative array in the same format returned by parseHeaderList().

If parsing failed, null is returned.

Parameters
string$eTag
Returns
array|null

Definition at line 68 of file IfNoneMatch.php.

References MediaWiki\Rest\HeaderParser\HeaderParserBase\assertEnd(), and MediaWiki\Rest\HeaderParser\HeaderParserBase\setInput().

Referenced by MediaWiki\Rest\ConditionalHeaderUtil\checkPreconditions().

◆ parseHeaderList()

MediaWiki\Rest\HeaderParser\IfNoneMatch::parseHeaderList ( $headerList)

Parse an If-None-Match or If-Match header list as returned by RequestInterface::getHeader().

The return value is an array of tag info arrays. Each tag info array is an associative array with the following keys:

  • weak: True if the tag is weak, false otherwise
  • contents: The contents of the double-quoted opaque-tag, not including the quotes.
  • whole: The whole ETag, including weak indicator and quoted opaque-tag

In the case of a wildcard header like "If-Match: *", there cannot be any other tags. The return value is an array with a single tag info array with 'whole' => '*'.

If the header was invalid, an empty array will be returned. Further information about why the parsing failed can be found by calling getLastError().

Parameters
string[]$headerList
Returns
array[]

Definition at line 37 of file IfNoneMatch.php.

References $header.


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