Skip to content

Commit

Permalink
Revert adding extra powered-by header
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Apr 7, 2024
1 parent c4f7924 commit ee4356f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/drivers/purgers/CloudflarePurger.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,18 @@ protected function defineRules(): array
return [
[
['apiToken'], 'required', 'when' => function(CloudflarePurger $purger) {
return $purger->authenticationMethod == 'apiToken';
},
return $purger->authenticationMethod == 'apiToken';
},
],
[
['apiKey', 'email'], 'required', 'when' => function(CloudflarePurger $purger) {
return $purger->authenticationMethod == 'apiKey';
},
return $purger->authenticationMethod == 'apiKey';
},
],
[
['email'], 'email', 'when' => function(CloudflarePurger $purger) {
return $purger->authenticationMethod == 'apiKey';
},
return $purger->authenticationMethod == 'apiKey';
},
],
];
}
Expand Down
12 changes: 8 additions & 4 deletions src/services/CacheRequestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,10 @@ private function addCraftHeaders(Response $response): void

// Send or remove the powered by header
if ($generalConfig->sendPoweredByHeader) {
$poweredByHeader = $headers->get(HeaderEnum::X_POWERED_BY, [], false);
$original = $headers->get(HeaderEnum::X_POWERED_BY);

if (!in_array(Craft::$app->name, $poweredByHeader)) {
$headers->add(HeaderEnum::X_POWERED_BY, Craft::$app->name);
if (!str_contains($original, Craft::$app->name)) {
$headers->set(HeaderEnum::X_POWERED_BY, $original . ($original ? ',' : '') . Craft::$app->name);
}
} else {
$headers->remove(HeaderEnum::X_POWERED_BY);
Expand Down Expand Up @@ -683,7 +683,11 @@ private function prepareResponse(Response $response, SiteUriModel $siteUri, bool
}

if (Blitz::$plugin->settings->sendPoweredByHeader) {
$headers->add(HeaderEnum::X_POWERED_BY, 'Blitz');
$original = $headers->get(HeaderEnum::X_POWERED_BY) ?? '';

if (!str_contains($original, 'Blitz')) {
$headers->set(HeaderEnum::X_POWERED_BY, $original . ($original ? ',' : '') . 'Blitz');
}
}

// Add cache tag header if set
Expand Down

0 comments on commit ee4356f

Please sign in to comment.