This commit is contained in:
RafficMohammed
2023-02-17 13:25:50 +05:30
parent 2381fd7cf5
commit 67950fc78f
891 changed files with 102300 additions and 138477 deletions

View File

@@ -29,17 +29,28 @@ class Store implements StoreInterface
private \SplObjectStorage $keyCache;
/** @var array<string, resource> */
private array $locks = [];
private array $options;
/**
* Constructor.
*
* The available options are:
*
* * private_headers Set of response headers that should not be stored
* when a response is cached. (default: Set-Cookie)
*
* @throws \RuntimeException
*/
public function __construct(string $root)
public function __construct(string $root, array $options = [])
{
$this->root = $root;
if (!is_dir($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) {
throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root));
}
$this->keyCache = new \SplObjectStorage();
$this->options = array_merge([
'private_headers' => ['Set-Cookie'],
], $options);
}
/**
@@ -212,6 +223,10 @@ class Store implements StoreInterface
$headers = $this->persistResponse($response);
unset($headers['age']);
foreach ($this->options['private_headers'] as $h) {
unset($headers[strtolower($h)]);
}
array_unshift($entries, [$storedEnv, $headers]);
if (!$this->save($key, serialize($entries))) {