diff options
| author | Greg Roach <fisharebest@gmail.com> | 2017-12-07 09:16:01 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@gmail.com> | 2017-12-07 09:16:01 +0000 |
| commit | 3e983931fdde6db78f1490364106d7d46e77dea7 (patch) | |
| tree | ad258a855a10b1096e7ff4fc4d5dc377b628b3ce /vendor/symfony/http-foundation/Response.php | |
| parent | ea51178689e8fd2aabc1dc599813355ef8b10ceb (diff) | |
| download | webtrees-3e983931fdde6db78f1490364106d7d46e77dea7.tar.gz webtrees-3e983931fdde6db78f1490364106d7d46e77dea7.tar.bz2 webtrees-3e983931fdde6db78f1490364106d7d46e77dea7.zip | |
Update to PhpUnit 6, for PHP 7
Diffstat (limited to 'vendor/symfony/http-foundation/Response.php')
| -rw-r--r-- | vendor/symfony/http-foundation/Response.php | 76 |
1 files changed, 33 insertions, 43 deletions
diff --git a/vendor/symfony/http-foundation/Response.php b/vendor/symfony/http-foundation/Response.php index e079ae2e95..4af1e0bae2 100644 --- a/vendor/symfony/http-foundation/Response.php +++ b/vendor/symfony/http-foundation/Response.php @@ -126,7 +126,6 @@ class Response 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', // RFC2518 - 103 => 'Early Hints', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', @@ -188,6 +187,8 @@ class Response ); /** + * Constructor. + * * @param mixed $content The response content, see setContent() * @param int $status The response status code * @param array $headers An array of response headers @@ -200,6 +201,11 @@ 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())); + } } /** @@ -255,6 +261,8 @@ class Response * compliant with RFC 2616. Most of the changes are based on * the Request that is "associated" with this Response. * + * @param Request $request A Request instance + * * @return $this */ public function prepare(Request $request) @@ -326,6 +334,11 @@ 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) { @@ -442,12 +455,12 @@ class Response /** * Sets the response status code. * - * If the status text is null it will be automatically populated for the known - * status codes and left empty otherwise. - * * @param int $code HTTP status code * @param mixed $text HTTP status text * + * If the status text is null it will be automatically populated for the known + * status codes and left empty otherwise. + * * @return $this * * @throws \InvalidArgumentException When the HTTP status code is not valid @@ -608,38 +621,6 @@ 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 @@ -667,12 +648,23 @@ 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'); } /** * Sets the Date header. * + * @param \DateTime $date A \DateTime instance + * * @return $this * * @final since version 3.2 @@ -964,7 +956,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', 'immutable'))) { + if ($diff = array_diff(array_keys($options), array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public'))) { throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', array_values($diff)))); } @@ -1000,10 +992,6 @@ class Response } } - if (isset($options['immutable'])) { - $this->setImmutable((bool) $options['immutable']); - } - return $this; } @@ -1089,6 +1077,8 @@ class Response * If the Response is not modified, it sets the status code to 304 and * removes the actual content by calling the setNotModified() method. * + * @param Request $request A Request instance + * * @return bool true if the Response validators match the Request, false otherwise * * @final since version 3.3 @@ -1271,7 +1261,7 @@ class Response // PHP_OUTPUT_HANDLER_* are not defined on HHVM 3.3 $flags = defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1; - while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || ($s['flags'] & $flags) === $flags : $s['del'])) { + while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || $flags === ($s['flags'] & $flags) : $s['del'])) { if ($flush) { ob_end_flush(); } else { @@ -1289,7 +1279,7 @@ class Response */ protected function ensureIEOverSSLCompatibility(Request $request) { - if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && 1 == preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) && true === $request->isSecure()) { + if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) { if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) { $this->headers->remove('Cache-Control'); } |
