30 public function setValidators( $eTag, $lastModified, $hasRepresentation ) {
31 $this->validatorsHaveBeenSet =
true;
33 if ( $lastModified ===
null ) {
34 $this->lastModified =
null;
36 $this->lastModified = (int)ConvertibleTimestamp::convert( TS_UNIX, $lastModified );
38 if ( $hasRepresentation ===
null ) {
39 $hasRepresentation = $eTag !==
null;
41 $this->hasRepresentation = $hasRepresentation;
64 if ( $this->eTag !==
null ) {
65 $resourceTag = $parser->
parseETag( $this->eTag );
66 if ( !$resourceTag ) {
67 throw new \Exception(
'Invalid ETag returned by handler: ' .
68 $parser->getLastError() );
73 $getOrHead = in_array( $request->
getMethod(), [
'GET',
'HEAD' ] );
74 if ( $request->
hasHeader(
'If-Match' ) ) {
77 foreach ( $parser->parseHeaderList( $im ) as $tag ) {
78 if ( $tag[
'whole'] ===
'*' && $this->hasRepresentation ) {
83 if ( $this->strongCompare( $resourceTag, $tag ) ) {
91 } elseif ( $request->
hasHeader(
'If-Unmodified-Since' ) ) {
93 if ( $requestDate !==
null
94 && ( $this->lastModified ===
null || $this->lastModified > $requestDate )
99 if ( $request->
hasHeader(
'If-None-Match' ) ) {
100 $inm = $request->
getHeader(
'If-None-Match' );
101 foreach ( $parser->parseHeaderList( $inm ) as $tag ) {
102 if ( $this->weakCompare( $resourceTag, $tag ) ) {
110 } elseif ( $getOrHead && $request->
hasHeader(
'If-Modified-Since' ) ) {
112 if ( $requestDate !==
null && $this->lastModified !==
null
113 && $this->lastModified <= $requestDate