class CommandLineOrUnsafeMethod in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUnsafeMethod.php \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod
- 9 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 RequestPolicyInterface
Expanded class hierarchy of CommandLineOrUnsafeMethod
2 files declare their use of CommandLineOrUnsafeMethod
- DefaultRequestPolicy.php in core/
lib/ Drupal/ Core/ PageCache/ DefaultRequestPolicy.php - DefaultRequestPolicy.php in core/
modules/ dynamic_page_cache/ src/ PageCache/ RequestPolicy/ 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CommandLineOrUnsafeMethod:: |
public | function |
Determines whether delivery of a cached page should be attempted. Overrides RequestPolicyInterface:: |
|
CommandLineOrUnsafeMethod:: |
protected | function | Indicates whether this is a CLI request. | |
RequestPolicyInterface:: |
constant | Allow delivery of cached pages. | ||
RequestPolicyInterface:: |
constant | Deny delivery of cached pages. |