class CommandLineOrUnsafeMethod
Same name in other branches
- 9 core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUnsafeMethod.php \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod
- 10 core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUnsafeMethod.php \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod
- 11.x core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUnsafeMethod.php \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod
Reject when running from the command line or when HTTP method is not safe.
The policy denies caching if the request was initiated from the command line interface (drush) or the request method is neither GET nor HEAD (see RFC 2616, section 9.1.1 - Safe Methods).
Hierarchy
- class \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod implements \Drupal\Core\PageCache\RequestPolicyInterface
Expanded class hierarchy of CommandLineOrUnsafeMethod
2 files declare their use of CommandLineOrUnsafeMethod
- DefaultRequestPolicy.php in core/
modules/ dynamic_page_cache/ src/ PageCache/ RequestPolicy/ DefaultRequestPolicy.php - DefaultRequestPolicy.php in core/
lib/ Drupal/ Core/ PageCache/ DefaultRequestPolicy.php
File
-
core/
lib/ Drupal/ Core/ PageCache/ RequestPolicy/ CommandLineOrUnsafeMethod.php, line 15
Namespace
Drupal\Core\PageCache\RequestPolicyView source
class CommandLineOrUnsafeMethod implements RequestPolicyInterface {
/**
* {@inheritdoc}
*/
public function check(Request $request) {
if ($this->isCli() || !$request->isMethodCacheable()) {
return static::DENY;
}
}
/**
* Indicates whether this is a CLI request.
*/
protected function isCli() {
return PHP_SAPI === 'cli';
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
CommandLineOrUnsafeMethod::check | public | function | Determines whether delivery of a cached page should be attempted. | Overrides RequestPolicyInterface::check |
CommandLineOrUnsafeMethod::isCli | protected | function | Indicates whether this is a CLI request. | |
RequestPolicyInterface::ALLOW | constant | Allow delivery of cached pages. | ||
RequestPolicyInterface::DENY | constant | Deny delivery of cached pages. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.