public function contentType() { $type = env('CONTENT_TYPE'); if ($type) { return $type; } return env('HTTP_CONTENT_TYPE'); }
/** * Test the content type method. * * @return void */ public function testContentType() { $_SERVER['HTTP_CONTENT_TYPE'] = 'application/json'; $request = new CakeRequest('/', false); $this->assertEquals('application/json', $request->contentType()); $_SERVER['CONTENT_TYPE'] = 'application/xml'; $request = new CakeRequest('/', false); $this->assertEquals('application/xml', $request->contentType(), 'prefer non http header.'); }