29 public function setValidators( $eTag, $lastModified, $hasRepresentation ) {
31 if ( $lastModified ===
null ) {
32 $this->lastModified =
null;
34 $this->lastModified = (int)ConvertibleTimestamp::convert( TS_UNIX, $lastModified );
36 $this->hasRepresentation = $hasRepresentation ?? ( $eTag !== null );
59 if ( $this->eTag !==
null ) {
60 $resourceTag = $parser->
parseETag( $this->eTag );
61 if ( !$resourceTag ) {
62 throw new \Exception(
'Invalid ETag returned by handler: ' .
63 $parser->getLastError() );
68 $getOrHead = in_array( $request->
getMethod(), [
'GET',
'HEAD' ] );
69 if ( $request->
hasHeader(
'If-Match' ) ) {
72 foreach ( $parser->parseHeaderList( $im ) as $tag ) {
73 if ( $tag[
'whole'] ===
'*' && $this->hasRepresentation ) {
78 if ( $this->strongCompare( $resourceTag, $tag ) ) {
86 } elseif ( $request->
hasHeader(
'If-Unmodified-Since' ) ) {
88 if ( $requestDate !==
null
89 && ( $this->lastModified ===
null || $this->lastModified > $requestDate )
94 if ( $request->
hasHeader(
'If-None-Match' ) ) {
95 $inm = $request->
getHeader(
'If-None-Match' );
96 foreach ( $parser->parseHeaderList( $inm ) as $tag ) {
97 if ( $tag[
'whole'] ===
'*' && $this->hasRepresentation ) {
98 return $getOrHead ? 304 : 412;
100 if ( $this->weakCompare( $resourceTag, $tag ) ) {
108 } elseif ( $getOrHead && $request->
hasHeader(
'If-Modified-Since' ) ) {
110 if ( $requestDate !==
null && $this->lastModified !==
null
111 && $this->lastModified <= $requestDate