Adding patch from 'dardosordi' fixes RequestHandler type detection with character set. Closes #5223

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7448 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2008-08-09 18:32:59 +00:00
parent cd09746201
commit 3a06f840c3
2 changed files with 16 additions and 3 deletions

View file

@ -468,9 +468,10 @@ class RequestHandlerComponent extends Object {
if (!$this->isPost() && !$this->isPut()) {
return null;
}
list($contentType) = explode(';', env('CONTENT_TYPE'));
if ($type == null) {
return $this->mapType(env('CONTENT_TYPE'));
return $this->mapType($contentType);
} elseif (is_array($type)) {
foreach ($type as $t) {
if ($this->requestedWith($t)) {
@ -479,7 +480,7 @@ class RequestHandlerComponent extends Object {
}
return false;
} elseif (is_string($type)) {
return ($type == $this->mapType(env('CONTENT_TYPE')));
return ($type == $this->mapType($contentType));
}
}
/**

View file

@ -177,6 +177,18 @@ class RequestHandlerComponentTest extends CakeTestCase {
$this->assertTrue(is_object($this->Controller->data));
$this->assertEqual(strtolower(get_class($this->Controller->data)), 'xml');
}
/**
* testStartupCallback with charset.
*
* @return void
**/
function testStartupCallbackCharset() {
$_SERVER['REQUEST_METHOD'] = 'PUT';
$_SERVER['CONTENT_TYPE'] = 'application/xml; charset=UTF-8';
$this->RequestHandler->startup($this->Controller);
$this->assertTrue(is_object($this->Controller->data));
$this->assertEqual(strtolower(get_class($this->Controller->data)), 'xml');
}
/**
* testNonAjaxRedirect method
*