mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request 1661 from 'sime/fallback-content-type' to master.
This commit is contained in:
commit
b1ea2d3a2b
2 changed files with 13 additions and 0 deletions
|
@ -518,6 +518,9 @@ class RequestHandlerComponent extends Component {
|
|||
}
|
||||
|
||||
list($contentType) = explode(';', env('CONTENT_TYPE'));
|
||||
if ($contentType === '') {
|
||||
list($contentType) = explode(';', CakeRequest::header('CONTENT_TYPE'));
|
||||
}
|
||||
if (!$type) {
|
||||
return $this->mapType($contentType);
|
||||
}
|
||||
|
|
|
@ -603,6 +603,16 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
$result = $this->RequestHandler->requestedWith(array('rss', 'atom'));
|
||||
$this->assertFalse($result);
|
||||
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
unset($_SERVER['CONTENT_TYPE']);
|
||||
$_SERVER['HTTP_CONTENT_TYPE'] = 'application/json';
|
||||
|
||||
$result = $this->RequestHandler->requestedWith(array('json', 'xml'));
|
||||
$this->assertEquals('json', $result);
|
||||
|
||||
$result = $this->RequestHandler->requestedWith(array('rss', 'atom'));
|
||||
$this->assertFalse($result);
|
||||
|
||||
$_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*';
|
||||
$this->assertTrue($this->RequestHandler->isXml());
|
||||
$this->assertFalse($this->RequestHandler->isAtom());
|
||||
|
|
Loading…
Reference in a new issue