Skip to content

Commit

Permalink
Fix the ETag handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dtdesign committed May 18, 2024
1 parent 075d05e commit 3ad1b81
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions wcfsetup/install/files/lib/action/FileDownloadAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,19 @@ public function handle(ServerRequestInterface $request): ResponseInterface
);

$httpIfNoneMatch = \array_map(
static fn ($tag) => \preg_replace('^"W/', '"', $tag),
Header::splitList($request->getHeaderLine('HTTP_IF_NONE_MATCH'))
static fn ($tag) => \preg_replace('~^"W/~', '"', $tag),
Header::splitList($request->getHeaderLine('if-none-match'))
);
if (\in_array($nonWeakETag, $httpIfNoneMatch, true)) {
return new EmptyResponse(304);
$emptyResponse = new EmptyResponse(304);
if ($response->getHeader('expires')) {
$emptyResponse = $emptyResponse->withHeader('expires', $response->getHeader('expires'));
}
if ($response->getHeader('cache-control')) {
$emptyResponse = $emptyResponse->withHeader('cache-control', $response->getHeader('cache-control'));
}

return $emptyResponse;
}

return $response
Expand Down

0 comments on commit 3ad1b81

Please sign in to comment.