const HTTP_UNPROCESSABLE_ENTITY = 422; // RFC4918
const HTTP_LOCKED = 423; // RFC4918
const HTTP_FAILED_DEPENDENCY = 424; // RFC4918
+
+ /**
+ * @deprecated
+ */
const HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817
+ const HTTP_TOO_EARLY = 425; // RFC-ietf-httpbis-replay-04
const HTTP_UPGRADE_REQUIRED = 426; // RFC2817
const HTTP_PRECONDITION_REQUIRED = 428; // RFC6585
const HTTP_TOO_MANY_REQUESTS = 429; // RFC6585
422 => 'Unprocessable Entity', // RFC4918
423 => 'Locked', // RFC4918
424 => 'Failed Dependency', // RFC4918
- 425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817
+ 425 => 'Too Early', // RFC-ietf-httpbis-replay-04
426 => 'Upgrade Required', // RFC2817
428 => 'Precondition Required', // RFC6585
429 => 'Too Many Requests', // RFC6585
}
// headers
- foreach ($this->headers->allPreserveCase() as $name => $values) {
+ foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) {
foreach ($values as $value) {
header($name.': '.$value, false, $this->statusCode);
}
}
+ // cookies
+ foreach ($this->headers->getCookies() as $cookie) {
+ header('Set-Cookie: '.$cookie->getName().strstr($cookie, '='), false, $this->statusCode);
+ }
+
// status
header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);
$this->sendHeaders();
$this->sendContent();
- if (function_exists('fastcgi_finish_request')) {
+ if (\function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
- } elseif (!\in_array(PHP_SAPI, array('cli', 'phpdbg'), true)) {
+ } elseif (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
static::closeOutputBuffers(0, true);
}
*/
public function setContent($content)
{
- if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable(array($content, '__toString'))) {
- throw new \UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', gettype($content)));
+ if (null !== $content && !\is_string($content) && !is_numeric($content) && !\is_callable(array($content, '__toString'))) {
+ throw new \UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', \gettype($content)));
}
$this->content = (string) $content;
*/
public function isCacheable()
{
- if (!in_array($this->statusCode, array(200, 203, 300, 301, 302, 404, 410))) {
+ if (!\in_array($this->statusCode, array(200, 203, 300, 301, 302, 404, 410))) {
return false;
}
{
if ($this->isFresh()) {
$this->headers->set('Age', $this->getMaxAge());
+ $this->headers->remove('Expires');
}
return $this;
public function setCache(array $options)
{
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))));
+ throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', $diff)));
}
if (isset($options['etag'])) {
$modifiedSince = $request->headers->get('If-Modified-Since');
if ($etags = $request->getETags()) {
- $notModified = in_array($this->getEtag(), $etags) || in_array('*', $etags);
+ $notModified = \in_array($this->getEtag(), $etags) || \in_array('*', $etags);
}
if ($modifiedSince && $lastModified) {
*/
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, array(201, 301, 302, 303, 307, 308)) && (null === $location ?: $location == $this->headers->get('Location'));
}
/**
*/
public function isEmpty()
{
- return in_array($this->statusCode, array(204, 304));
+ return \in_array($this->statusCode, array(204, 304));
}
/**
public static function closeOutputBuffers($targetLevel, $flush)
{
$status = ob_get_status(true);
- $level = count($status);
+ $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;
+ $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'])) {
if ($flush) {