511 => 'Network Authentication Required', // RFC6585
);
+ private static $deprecatedMethods = array(
+ 'setDate', 'getDate',
+ 'setExpires', 'getExpires',
+ 'setLastModified', 'getLastModified',
+ 'setProtocolVersion', 'getProtocolVersion',
+ 'setStatusCode', 'getStatusCode',
+ 'setCharset', 'getCharset',
+ 'setPrivate', 'setPublic',
+ 'getAge', 'getMaxAge', 'setMaxAge', 'setSharedMaxAge',
+ 'getTtl', 'setTtl', 'setClientTtl',
+ 'getEtag', 'setEtag',
+ 'hasVary', 'getVary', 'setVary',
+ 'isInvalid', 'isSuccessful', 'isRedirection',
+ 'isClientError', 'isOk', 'isForbidden',
+ 'isNotFound', 'isRedirect', 'isEmpty',
+ );
+ private static $deprecationsTriggered = array(
+ __CLASS__ => true,
+ BinaryFileResponse::class => true,
+ JsonResponse::class => true,
+ RedirectResponse::class => true,
+ StreamedResponse::class => true,
+ );
+
/**
* Constructor.
*
if (!$this->headers->has('Date')) {
$this->setDate(\DateTime::createFromFormat('U', time()));
}
+
+ // Deprecations
+ $class = get_class($this);
+ if ($this instanceof \PHPUnit_Framework_MockObject_MockObject || $this instanceof \Prophecy\Doubler\DoubleInterface) {
+ $class = get_parent_class($class);
+ }
+ if (isset(self::$deprecationsTriggered[$class])) {
+ return;
+ }
+
+ self::$deprecationsTriggered[$class] = true;
+ foreach (self::$deprecatedMethods as $method) {
+ $r = new \ReflectionMethod($class, $method);
+ if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
+ @trigger_error(sprintf('Extending %s::%s() in %s is deprecated since version 3.2 and won\'t be supported anymore in 4.0 as it will be final.', __CLASS__, $method, $class), E_USER_DEPRECATED);
+ }
+ }
}
/**
}
// Check if we need to send extra expire info headers
- if ('1.0' == $this->getProtocolVersion() && 'no-cache' == $this->headers->get('Cache-Control')) {
+ if ('1.0' == $this->getProtocolVersion() && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) {
$this->headers->set('pragma', 'no-cache');
$this->headers->set('expires', -1);
}
// cookies
foreach ($this->headers->getCookies() as $cookie) {
- setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
+ if ($cookie->isRaw()) {
+ setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
+ } else {
+ setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
+ }
}
return $this;
{
$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']) || $flags === ($s['flags'] & $flags) : $s['del'])) {