30 public function setValidators( $eTag, $lastModified, $hasRepresentation ) {
32 if ( $lastModified ===
null ) {
33 $this->lastModified =
null;
35 $this->lastModified = (int)ConvertibleTimestamp::convert( TS_UNIX, $lastModified );
37 $this->hasRepresentation = $hasRepresentation ?? ( $eTag !== null );
60 if ( $this->eTag !==
null ) {
61 $resourceTag = $parser->
parseETag( $this->eTag );
62 if ( !$resourceTag ) {
63 throw new RuntimeException(
'Invalid ETag returned by handler: `' .
64 $parser->getLastError() .
'`' );
69 $getOrHead = in_array( $request->
getMethod(), [
'GET',
'HEAD' ] );
70 if ( $request->
hasHeader(
'If-Match' ) ) {
73 foreach ( $parser->parseHeaderList( $im ) as $tag ) {
74 if ( $tag[
'whole'] ===
'*' && $this->hasRepresentation ) {
79 if ( $this->strongCompare( $resourceTag, $tag ) ) {
87 } elseif ( $request->
hasHeader(
'If-Unmodified-Since' ) ) {
89 if ( $requestDate !==
null
90 && ( $this->lastModified ===
null || $this->lastModified > $requestDate )
95 if ( $request->
hasHeader(
'If-None-Match' ) ) {
96 $inm = $request->
getHeader(
'If-None-Match' );
97 foreach ( $parser->parseHeaderList( $inm ) as $tag ) {
98 if ( $tag[
'whole'] ===
'*' && $this->hasRepresentation ) {
99 return $getOrHead ? 304 : 412;
101 if ( $this->weakCompare( $resourceTag, $tag ) ) {
109 } elseif ( $getOrHead && $request->
hasHeader(
'If-Modified-Since' ) ) {
111 if ( $requestDate !==
null && $this->lastModified !==
null
112 && $this->lastModified <= $requestDate