Changing behavior of RequestHandlerComponent::responseType(), it will return the current content type set int the response object

It will not return null as default as it did prior 2.0
This commit is contained in:
José Lorenzo Rodríguez 2010-08-02 19:21:52 -04:30
parent 1acbf15c00
commit e7c7008781
2 changed files with 2 additions and 15 deletions

View file

@ -47,15 +47,6 @@ class RequestHandlerComponent extends Object {
*/
public $enabled = true;
/**
* Holds the content-type of the response that is set when using
* RequestHandler::respondAs()
*
* @var string
* @access private
*/
private $__responseTypeSet = null;
/**
* Holds the reference to Controller::$request
*
@ -566,7 +557,6 @@ class RequestHandlerComponent extends Object {
if (!empty($options['attachment'])) {
$this->response->download($options['attachment']);
}
$this->__responseTypeSet = $cType;
return true;
}
return false;
@ -579,10 +569,7 @@ class RequestHandlerComponent extends Object {
* otherwise null
*/
public function responseType() {
if ($this->__responseTypeSet == null) {
return null;
}
return $this->mapType($this->__responseTypeSet);
return $this->mapType($this->response->type());
}
/**

View file

@ -442,7 +442,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
* @return void
*/
function testResponseContentType() {
$this->assertNull($this->RequestHandler->responseType());
$this->assertEquals('html', $this->RequestHandler->responseType());
$this->assertTrue($this->RequestHandler->respondAs('atom'));
$this->assertEqual($this->RequestHandler->responseType(), 'atom');
}