Not sending a content-length for redirection status codes that are not supposed to have any content

This commit is contained in:
José Lorenzo Rodríguez 2011-10-27 22:44:42 -05:30
parent aabfad9a09
commit 29ca42ed7a

View file

@ -351,8 +351,8 @@ class CakeResponse {
$this->_sendHeader("{$this->_protocol} {$this->_status} {$codeMessage}"); $this->_sendHeader("{$this->_protocol} {$this->_status} {$codeMessage}");
$this->_sendHeader('Content-Type', "{$this->_contentType}; charset={$this->_charset}"); $this->_sendHeader('Content-Type', "{$this->_contentType}; charset={$this->_charset}");
$shouldSetLength = empty($this->_headers['Content-Length']) && class_exists('Multibyte'); $shouldSetLength = empty($this->_headers['Content-Length']) && class_exists('Multibyte');
$shouldSetLength = $shouldSetLength && !$this->outputCompressed(); $shouldSetLength = $shouldSetLength && !in_array($this->_status, range(301, 307));
if ($shouldSetLength) { if ($shouldSetLength && !$this->outputCompressed()) {
$this->_headers['Content-Length'] = mb_strlen($this->_body); $this->_headers['Content-Length'] = mb_strlen($this->_body);
} }
foreach ($this->_headers as $header => $value) { foreach ($this->_headers as $header => $value) {