mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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:
parent
cd09746201
commit
3a06f840c3
2 changed files with 16 additions and 3 deletions
|
@ -468,9 +468,10 @@ class RequestHandlerComponent extends Object {
|
||||||
if (!$this->isPost() && !$this->isPut()) {
|
if (!$this->isPost() && !$this->isPut()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list($contentType) = explode(';', env('CONTENT_TYPE'));
|
||||||
if ($type == null) {
|
if ($type == null) {
|
||||||
return $this->mapType(env('CONTENT_TYPE'));
|
return $this->mapType($contentType);
|
||||||
} elseif (is_array($type)) {
|
} elseif (is_array($type)) {
|
||||||
foreach ($type as $t) {
|
foreach ($type as $t) {
|
||||||
if ($this->requestedWith($t)) {
|
if ($this->requestedWith($t)) {
|
||||||
|
@ -479,7 +480,7 @@ class RequestHandlerComponent extends Object {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} elseif (is_string($type)) {
|
} elseif (is_string($type)) {
|
||||||
return ($type == $this->mapType(env('CONTENT_TYPE')));
|
return ($type == $this->mapType($contentType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -177,6 +177,18 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
||||||
$this->assertTrue(is_object($this->Controller->data));
|
$this->assertTrue(is_object($this->Controller->data));
|
||||||
$this->assertEqual(strtolower(get_class($this->Controller->data)), 'xml');
|
$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
|
* testNonAjaxRedirect method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue