mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding protocol() method to CakeResponse to be able to change it on the fly
This commit is contained in:
parent
6211be2acc
commit
336ba1965e
2 changed files with 27 additions and 0 deletions
|
@ -683,6 +683,19 @@ class CakeResponse {
|
|||
$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.
|
||||
|
|
|
@ -500,4 +500,18 @@ class CakeResponseTest extends CakeTestCase {
|
|||
$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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue