Skip to content

Commit

Permalink
Adding protocol() method to CakeResponse to be able to change it on t…
Browse files Browse the repository at this point in the history
…he fly
  • Loading branch information
lorenzo committed Jan 19, 2012
1 parent 6211be2 commit 336ba19
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/Cake/Network/CakeResponse.php
Expand Up @@ -683,6 +683,19 @@ public function download($filename) {
$this->header('Content-Disposition', 'attachment; filename="' . $filename . '"');
}

/**
* Sets the protocol to be used when sending the response. Defaults to HTTP/1.1
* If called with no arguments, it will return the current configured protocol
*
* @return string protocol to be used for sending response
*/
public function protocol($protocol = null) {
if ($protocol !== null) {
$this->_protocol = $protocol;
}
return $this->_protocol;
}

/**
* String conversion. Fetches the response body as a string.
* Does *not* send headers.
Expand Down
14 changes: 14 additions & 0 deletions lib/Cake/Test/Case/Network/CakeResponseTest.php
Expand Up @@ -500,4 +500,18 @@ public function testSendContentLength() {
$response->send();
ob_end_clean();
}

/**
* Tests getting/setting the protocol
*
* @return void
*/
public function testProtocol() {
$response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent'));
$response->protocol('HTTP/1.0');
$this->assertEquals('HTTP/1.0', $response->protocol());
$response->expects($this->at(0))
->method('_sendHeader')->with('HTTP/1.0 200 OK');
$response->send();
}
}

0 comments on commit 336ba19

Please sign in to comment.