diff options
| author | Greg Roach <fisharebest@gmail.com> | 2017-12-05 18:35:16 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2017-12-05 18:35:16 +0000 |
| commit | 7ace898ae2c4a9c68bfc303be4ca9ce044f6c8fb (patch) | |
| tree | 540514de76ddd7a7b48c45e6f343982c75e459f6 /vendor/symfony/http-foundation/Response.php | |
| parent | 52eaf96b933551ac480679c3439951cf6b04a3f0 (diff) | |
| download | webtrees-7ace898ae2c4a9c68bfc303be4ca9ce044f6c8fb.tar.gz webtrees-7ace898ae2c4a9c68bfc303be4ca9ce044f6c8fb.tar.bz2 webtrees-7ace898ae2c4a9c68bfc303be4ca9ce044f6c8fb.zip | |
Update symfony/http-foundation from 3.3 to 3.4
Diffstat (limited to 'vendor/symfony/http-foundation/Response.php')
| -rw-r--r-- | vendor/symfony/http-foundation/Response.php | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/vendor/symfony/http-foundation/Response.php b/vendor/symfony/http-foundation/Response.php index d7d30f0c26..e079ae2e95 100644 --- a/vendor/symfony/http-foundation/Response.php +++ b/vendor/symfony/http-foundation/Response.php @@ -200,11 +200,6 @@ class Response $this->setContent($content); $this->setStatusCode($status); $this->setProtocolVersion('1.0'); - - /* RFC2616 - 14.18 says all Responses need to have a Date */ - if (!$this->headers->has('Date')) { - $this->setDate(\DateTime::createFromFormat('U', time())); - } } /** @@ -331,11 +326,6 @@ class Response return $this; } - /* RFC2616 - 14.18 says all Responses need to have a Date */ - if (!$this->headers->has('Date')) { - $this->setDate(\DateTime::createFromFormat('U', time())); - } - // headers foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) { foreach ($values as $value) { @@ -618,6 +608,38 @@ class Response } /** + * Marks the response as "immutable". + * + * @param bool $immutable enables or disables the immutable directive + * + * @return $this + * + * @final + */ + public function setImmutable($immutable = true) + { + if ($immutable) { + $this->headers->addCacheControlDirective('immutable'); + } else { + $this->headers->removeCacheControlDirective('immutable'); + } + + return $this; + } + + /** + * Returns true if the response is marked as "immutable". + * + * @return bool returns true if the response is marked as "immutable"; otherwise false + * + * @final + */ + public function isImmutable() + { + return $this->headers->hasCacheControlDirective('immutable'); + } + + /** * Returns true if the response must be revalidated by caches. * * This method indicates that the response must not be served stale by a @@ -645,15 +667,6 @@ class Response */ public function getDate() { - /* - RFC2616 - 14.18 says all Responses need to have a Date. - Make sure we provide one even if it the header - has been removed in the meantime. - */ - if (!$this->headers->has('Date')) { - $this->setDate(\DateTime::createFromFormat('U', time())); - } - return $this->headers->getDate('Date'); } @@ -951,7 +964,7 @@ class Response */ public function setCache(array $options) { - if ($diff = array_diff(array_keys($options), array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public'))) { + if ($diff = array_diff(array_keys($options), array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public', 'immutable'))) { throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', array_values($diff)))); } @@ -987,6 +1000,10 @@ class Response } } + if (isset($options['immutable'])) { + $this->setImmutable((bool) $options['immutable']); + } + return $this; } |
