Augmentation vers version 3.3.0
This commit is contained in:
212
vendor/symfony/http-foundation/Response.php
vendored
212
vendor/symfony/http-foundation/Response.php
vendored
@@ -88,7 +88,7 @@ class Response
|
||||
const HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511; // RFC6585
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\HttpFoundation\ResponseHeaderBag
|
||||
* @var ResponseHeaderBag
|
||||
*/
|
||||
public $headers;
|
||||
|
||||
@@ -121,14 +121,14 @@ class Response
|
||||
* Status codes translation table.
|
||||
*
|
||||
* The list of codes is complete according to the
|
||||
* {@link http://www.iana.org/assignments/http-status-codes/ Hypertext Transfer Protocol (HTTP) Status Code Registry}
|
||||
* {@link https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml Hypertext Transfer Protocol (HTTP) Status Code Registry}
|
||||
* (last updated 2016-03-01).
|
||||
*
|
||||
* Unless otherwise noted, the status code is defined in RFC2616.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $statusTexts = array(
|
||||
public static $statusTexts = [
|
||||
100 => 'Continue',
|
||||
101 => 'Switching Protocols',
|
||||
102 => 'Processing', // RFC2518
|
||||
@@ -191,7 +191,7 @@ class Response
|
||||
508 => 'Loop Detected', // RFC5842
|
||||
510 => 'Not Extended', // RFC2774
|
||||
511 => 'Network Authentication Required', // RFC6585
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @param mixed $content The response content, see setContent()
|
||||
@@ -200,17 +200,12 @@ class Response
|
||||
*
|
||||
* @throws \InvalidArgumentException When the HTTP status code is not valid
|
||||
*/
|
||||
public function __construct($content = '', $status = 200, $headers = array())
|
||||
public function __construct($content = '', $status = 200, $headers = [])
|
||||
{
|
||||
$this->headers = new ResponseHeaderBag($headers);
|
||||
$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()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,7 +222,7 @@ class Response
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create($content = '', $status = 200, $headers = array())
|
||||
public static function create($content = '', $status = 200, $headers = [])
|
||||
{
|
||||
return new static($content, $status, $headers);
|
||||
}
|
||||
@@ -315,9 +310,9 @@ class Response
|
||||
}
|
||||
|
||||
// Check if we need to send extra expire info headers
|
||||
if ('1.0' == $this->getProtocolVersion() && 'no-cache' == $this->headers->get('Cache-Control')) {
|
||||
$this->headers->set('pragma', 'no-cache');
|
||||
$this->headers->set('expires', -1);
|
||||
if ('1.0' == $this->getProtocolVersion() && false !== strpos($headers->get('Cache-Control'), 'no-cache')) {
|
||||
$headers->set('pragma', 'no-cache');
|
||||
$headers->set('expires', -1);
|
||||
}
|
||||
|
||||
$this->ensureIEOverSSLCompatibility($request);
|
||||
@@ -337,27 +332,22 @@ 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->allPreserveCase() as $name => $values) {
|
||||
foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) {
|
||||
$replace = 0 === strcasecmp($name, 'Content-Type');
|
||||
foreach ($values as $value) {
|
||||
header($name.': '.$value, $replace, $this->statusCode);
|
||||
}
|
||||
}
|
||||
|
||||
// status
|
||||
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
|
||||
|
||||
// cookies
|
||||
foreach ($this->headers->getCookies() as $cookie) {
|
||||
setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
|
||||
header('Set-Cookie: '.$cookie, false, $this->statusCode);
|
||||
}
|
||||
|
||||
// status
|
||||
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -385,7 +375,7 @@ class Response
|
||||
|
||||
if (\function_exists('fastcgi_finish_request')) {
|
||||
fastcgi_finish_request();
|
||||
} elseif (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
|
||||
} elseif (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
|
||||
static::closeOutputBuffers(0, true);
|
||||
}
|
||||
|
||||
@@ -405,7 +395,7 @@ class Response
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
if (null !== $content && !\is_string($content) && !is_numeric($content) && !\is_callable(array($content, '__toString'))) {
|
||||
if (null !== $content && !\is_string($content) && !is_numeric($content) && !\is_callable([$content, '__toString'])) {
|
||||
throw new \UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', \gettype($content)));
|
||||
}
|
||||
|
||||
@@ -417,7 +407,7 @@ class Response
|
||||
/**
|
||||
* Gets the current response content.
|
||||
*
|
||||
* @return string Content
|
||||
* @return string|false
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
@@ -430,6 +420,8 @@ class Response
|
||||
* @param string $version The HTTP protocol version
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setProtocolVersion($version)
|
||||
{
|
||||
@@ -442,6 +434,8 @@ class Response
|
||||
* Gets the HTTP protocol version.
|
||||
*
|
||||
* @return string The HTTP protocol version
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function getProtocolVersion()
|
||||
{
|
||||
@@ -460,6 +454,8 @@ class Response
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException When the HTTP status code is not valid
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setStatusCode($code, $text = null)
|
||||
{
|
||||
@@ -489,6 +485,8 @@ class Response
|
||||
* Retrieves the status code for the current web response.
|
||||
*
|
||||
* @return int Status code
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
@@ -501,6 +499,8 @@ class Response
|
||||
* @param string $charset Character set
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setCharset($charset)
|
||||
{
|
||||
@@ -513,6 +513,8 @@ class Response
|
||||
* Retrieves the response charset.
|
||||
*
|
||||
* @return string Character set
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function getCharset()
|
||||
{
|
||||
@@ -535,10 +537,12 @@ class Response
|
||||
* (https://tools.ietf.org/html/rfc7231#section-6.1)
|
||||
*
|
||||
* @return bool true if the response is worth caching, false otherwise
|
||||
*
|
||||
* @final since version 3.3
|
||||
*/
|
||||
public function isCacheable()
|
||||
{
|
||||
if (!\in_array($this->statusCode, array(200, 203, 300, 301, 302, 404, 410))) {
|
||||
if (!\in_array($this->statusCode, [200, 203, 300, 301, 302, 404, 410])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -557,6 +561,8 @@ class Response
|
||||
* indicator or Expires header and the calculated age is less than the freshness lifetime.
|
||||
*
|
||||
* @return bool true if the response is fresh, false otherwise
|
||||
*
|
||||
* @final since version 3.3
|
||||
*/
|
||||
public function isFresh()
|
||||
{
|
||||
@@ -568,6 +574,8 @@ class Response
|
||||
* the response with the origin server using a conditional GET request.
|
||||
*
|
||||
* @return bool true if the response is validateable, false otherwise
|
||||
*
|
||||
* @final since version 3.3
|
||||
*/
|
||||
public function isValidateable()
|
||||
{
|
||||
@@ -580,6 +588,8 @@ class Response
|
||||
* It makes the response ineligible for serving other clients.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setPrivate()
|
||||
{
|
||||
@@ -595,6 +605,8 @@ class Response
|
||||
* It makes the response eligible for serving other clients.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setPublic()
|
||||
{
|
||||
@@ -604,6 +616,38 @@ class Response
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@@ -613,6 +657,8 @@ class Response
|
||||
* greater than the value provided by the origin.
|
||||
*
|
||||
* @return bool true if the response must be revalidated by a cache, false otherwise
|
||||
*
|
||||
* @final since version 3.3
|
||||
*/
|
||||
public function mustRevalidate()
|
||||
{
|
||||
@@ -625,18 +671,11 @@ class Response
|
||||
* @return \DateTime A \DateTime instance
|
||||
*
|
||||
* @throws \RuntimeException When the header is not parseable
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
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');
|
||||
}
|
||||
|
||||
@@ -644,6 +683,8 @@ class Response
|
||||
* Sets the Date header.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setDate(\DateTime $date)
|
||||
{
|
||||
@@ -657,6 +698,8 @@ class Response
|
||||
* Returns the age of the response.
|
||||
*
|
||||
* @return int The age of the response in seconds
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function getAge()
|
||||
{
|
||||
@@ -664,7 +707,7 @@ class Response
|
||||
return (int) $age;
|
||||
}
|
||||
|
||||
return max(time() - $this->getDate()->format('U'), 0);
|
||||
return max(time() - (int) $this->getDate()->format('U'), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -686,6 +729,8 @@ class Response
|
||||
* Returns the value of the Expires header as a DateTime instance.
|
||||
*
|
||||
* @return \DateTime|null A DateTime instance or null if the header does not exist
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function getExpires()
|
||||
{
|
||||
@@ -705,6 +750,8 @@ class Response
|
||||
* @param \DateTime|null $date A \DateTime instance or null to remove the header
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setExpires(\DateTime $date = null)
|
||||
{
|
||||
@@ -727,6 +774,8 @@ class Response
|
||||
* back on an expires header. It returns null when no maximum age can be established.
|
||||
*
|
||||
* @return int|null Number of seconds
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function getMaxAge()
|
||||
{
|
||||
@@ -739,8 +788,10 @@ class Response
|
||||
}
|
||||
|
||||
if (null !== $this->getExpires()) {
|
||||
return $this->getExpires()->format('U') - $this->getDate()->format('U');
|
||||
return (int) $this->getExpires()->format('U') - (int) $this->getDate()->format('U');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -751,6 +802,8 @@ class Response
|
||||
* @param int $value Number of seconds
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setMaxAge($value)
|
||||
{
|
||||
@@ -767,6 +820,8 @@ class Response
|
||||
* @param int $value Number of seconds
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setSharedMaxAge($value)
|
||||
{
|
||||
@@ -785,12 +840,16 @@ class Response
|
||||
* revalidating with the origin.
|
||||
*
|
||||
* @return int|null The TTL in seconds
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function getTtl()
|
||||
{
|
||||
if (null !== $maxAge = $this->getMaxAge()) {
|
||||
return $maxAge - $this->getAge();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -801,6 +860,8 @@ class Response
|
||||
* @param int $seconds Number of seconds
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setTtl($seconds)
|
||||
{
|
||||
@@ -817,6 +878,8 @@ class Response
|
||||
* @param int $seconds Number of seconds
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setClientTtl($seconds)
|
||||
{
|
||||
@@ -831,6 +894,8 @@ class Response
|
||||
* @return \DateTime|null A DateTime instance or null if the header does not exist
|
||||
*
|
||||
* @throws \RuntimeException When the HTTP header is not parseable
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function getLastModified()
|
||||
{
|
||||
@@ -845,6 +910,8 @@ class Response
|
||||
* @param \DateTime|null $date A \DateTime instance or null to remove the header
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setLastModified(\DateTime $date = null)
|
||||
{
|
||||
@@ -863,6 +930,8 @@ class Response
|
||||
* Returns the literal value of the ETag HTTP header.
|
||||
*
|
||||
* @return string|null The ETag HTTP header or null if it does not exist
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function getEtag()
|
||||
{
|
||||
@@ -876,6 +945,8 @@ class Response
|
||||
* @param bool $weak Whether you want a weak ETag or not
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setEtag($etag = null, $weak = false)
|
||||
{
|
||||
@@ -895,18 +966,20 @@ class Response
|
||||
/**
|
||||
* Sets the response's cache headers (validation and/or expiration).
|
||||
*
|
||||
* Available options are: etag, last_modified, max_age, s_maxage, private, and public.
|
||||
* Available options are: etag, last_modified, max_age, s_maxage, private, public and immutable.
|
||||
*
|
||||
* @param array $options An array of cache options
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @final since version 3.3
|
||||
*/
|
||||
public function setCache(array $options)
|
||||
{
|
||||
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))));
|
||||
if ($diff = array_diff(array_keys($options), ['etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public', 'immutable'])) {
|
||||
throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', $diff)));
|
||||
}
|
||||
|
||||
if (isset($options['etag'])) {
|
||||
@@ -941,6 +1014,10 @@ class Response
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($options['immutable'])) {
|
||||
$this->setImmutable((bool) $options['immutable']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -952,7 +1029,9 @@ class Response
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @see http://tools.ietf.org/html/rfc2616#section-10.3.5
|
||||
* @see https://tools.ietf.org/html/rfc2616#section-10.3.5
|
||||
*
|
||||
* @final since version 3.3
|
||||
*/
|
||||
public function setNotModified()
|
||||
{
|
||||
@@ -960,7 +1039,7 @@ class Response
|
||||
$this->setContent(null);
|
||||
|
||||
// remove headers that MUST NOT be included with 304 Not Modified responses
|
||||
foreach (array('Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified') as $header) {
|
||||
foreach (['Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified'] as $header) {
|
||||
$this->headers->remove($header);
|
||||
}
|
||||
|
||||
@@ -971,6 +1050,8 @@ class Response
|
||||
* Returns true if the response includes a Vary header.
|
||||
*
|
||||
* @return bool true if the response includes a Vary header, false otherwise
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function hasVary()
|
||||
{
|
||||
@@ -981,14 +1062,16 @@ class Response
|
||||
* Returns an array of header names given in the Vary header.
|
||||
*
|
||||
* @return array An array of Vary names
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function getVary()
|
||||
{
|
||||
if (!$vary = $this->headers->get('Vary', null, false)) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
foreach ($vary as $item) {
|
||||
$ret = array_merge($ret, preg_split('/[\s,]+/', $item));
|
||||
}
|
||||
@@ -1003,6 +1086,8 @@ class Response
|
||||
* @param bool $replace Whether to replace the actual value or not (true by default)
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function setVary($headers, $replace = true)
|
||||
{
|
||||
@@ -1019,6 +1104,8 @@ class Response
|
||||
* removes the actual content by calling the setNotModified() method.
|
||||
*
|
||||
* @return bool true if the Response validators match the Request, false otherwise
|
||||
*
|
||||
* @final since version 3.3
|
||||
*/
|
||||
public function isNotModified(Request $request)
|
||||
{
|
||||
@@ -1050,7 +1137,9 @@ class Response
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
|
||||
* @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function isInvalid()
|
||||
{
|
||||
@@ -1061,6 +1150,8 @@ class Response
|
||||
* Is response informative?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @final since version 3.3
|
||||
*/
|
||||
public function isInformational()
|
||||
{
|
||||
@@ -1071,6 +1162,8 @@ class Response
|
||||
* Is response successful?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function isSuccessful()
|
||||
{
|
||||
@@ -1081,6 +1174,8 @@ class Response
|
||||
* Is the response a redirect?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function isRedirection()
|
||||
{
|
||||
@@ -1091,6 +1186,8 @@ class Response
|
||||
* Is there a client error?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function isClientError()
|
||||
{
|
||||
@@ -1101,6 +1198,8 @@ class Response
|
||||
* Was there a server side error?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @final since version 3.3
|
||||
*/
|
||||
public function isServerError()
|
||||
{
|
||||
@@ -1111,6 +1210,8 @@ class Response
|
||||
* Is the response OK?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function isOk()
|
||||
{
|
||||
@@ -1121,6 +1222,8 @@ class Response
|
||||
* Is the response forbidden?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function isForbidden()
|
||||
{
|
||||
@@ -1131,6 +1234,8 @@ class Response
|
||||
* Is the response a not found error?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function isNotFound()
|
||||
{
|
||||
@@ -1143,20 +1248,24 @@ class Response
|
||||
* @param string $location
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function isRedirect($location = null)
|
||||
{
|
||||
return \in_array($this->statusCode, array(201, 301, 302, 303, 307, 308)) && (null === $location ?: $location == $this->headers->get('Location'));
|
||||
return \in_array($this->statusCode, [201, 301, 302, 303, 307, 308]) && (null === $location ?: $location == $this->headers->get('Location'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the response empty?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @final since version 3.2
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
return \in_array($this->statusCode, array(204, 304));
|
||||
return \in_array($this->statusCode, [204, 304]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1166,11 +1275,14 @@ class Response
|
||||
*
|
||||
* @param int $targetLevel The target output buffering level
|
||||
* @param bool $flush Whether to flush or clean the buffers
|
||||
*
|
||||
* @final since version 3.3
|
||||
*/
|
||||
public static function closeOutputBuffers($targetLevel, $flush)
|
||||
{
|
||||
$status = ob_get_status(true);
|
||||
$level = \count($status);
|
||||
// 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'])) {
|
||||
@@ -1186,6 +1298,8 @@ class Response
|
||||
* Checks if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9.
|
||||
*
|
||||
* @see http://support.microsoft.com/kb/323308
|
||||
*
|
||||
* @final since version 3.3
|
||||
*/
|
||||
protected function ensureIEOverSSLCompatibility(Request $request)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user