MediaWiki REL1_35
MediaWiki\Rest\HeaderParser\IfNoneMatch Class Reference

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

Inheritance diagram for MediaWiki\Rest\HeaderParser\IfNoneMatch:
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().
 

Private Member Functions

 consumeTag ()
 Consume a single entity-tag and append to the result array.
 
 consumeTagList ()
 Consume a comma-separated list of entity-tags.
 
 parseHeader ( $header)
 Parse a single header.
 

Private Attributes

string null $lastError
 
 $results = []
 

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

◆ consumeTag()

MediaWiki\Rest\HeaderParser\IfNoneMatch::consumeTag ( )
private

Consume a single entity-tag and append to the result array.

Exceptions
HeaderParserError

Definition at line 127 of file IfNoneMatch.php.

References MediaWiki\Rest\HeaderParser\HeaderParserBase\consumeString(), and MediaWiki\Rest\HeaderParser\HeaderParserBase\error().

Referenced by MediaWiki\Rest\HeaderParser\IfNoneMatch\consumeTagList(), and MediaWiki\Rest\HeaderParser\IfNoneMatch\parseETag().

◆ consumeTagList()

MediaWiki\Rest\HeaderParser\IfNoneMatch::consumeTagList ( )
private

◆ 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.

References MediaWiki\Rest\HeaderParser\IfNoneMatch\$lastError.

◆ 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(), MediaWiki\Rest\HeaderParser\IfNoneMatch\consumeTag(), and MediaWiki\Rest\HeaderParser\HeaderParserBase\setInput().

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

◆ parseHeader()

MediaWiki\Rest\HeaderParser\IfNoneMatch::parseHeader (   $header)
private

◆ 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, MediaWiki\Rest\HeaderParser\IfNoneMatch\$results, and MediaWiki\Rest\HeaderParser\IfNoneMatch\parseHeader().

Member Data Documentation

◆ $lastError

string null MediaWiki\Rest\HeaderParser\IfNoneMatch::$lastError
private

◆ $results

MediaWiki\Rest\HeaderParser\IfNoneMatch::$results = []
private

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