Skip to content

Commit

Permalink
return byte length instead of number of characters in Content-Length
Browse files Browse the repository at this point in the history
  • Loading branch information
ichikaway committed Oct 31, 2011
1 parent 7141dff commit e532875
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/Cake/Network/CakeResponse.php
Expand Up @@ -350,10 +350,9 @@ public function send() {
$codeMessage = $this->_statusCodes[$this->_status];
$this->_sendHeader("{$this->_protocol} {$this->_status} {$codeMessage}");
$this->_sendHeader('Content-Type', "{$this->_contentType}; charset={$this->_charset}");
$shouldSetLength = empty($this->_headers['Content-Length']) && class_exists('Multibyte');
$shouldSetLength = $shouldSetLength && !in_array($this->_status, range(301, 307));
$shouldSetLength = empty($this->_headers['Content-Length']) && !in_array($this->_status, range(301, 307));
if ($shouldSetLength && !$this->outputCompressed()) {
$this->_headers['Content-Length'] = mb_strlen($this->_body);
$this->_headers['Content-Length'] = strlen($this->_body);
}
foreach ($this->_headers as $header => $value) {
$this->_sendHeader($header, $value);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Network/CakeResponseTest.php
Expand Up @@ -396,7 +396,7 @@ public function testSendContentLength() {
$response->expects($this->at(1))
->method('_sendHeader')->with('Content-Type', 'text/html; charset=UTF-8');
$response->expects($this->at(2))
->method('_sendHeader')->with('Content-Length', mb_strlen($body));
->method('_sendHeader')->with('Content-Length', 116);
$response->send();

$response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', 'outputCompressed'));
Expand Down

0 comments on commit e532875

Please sign in to comment.