diff --git a/Cake/Network/Response.php b/Cake/Network/Response.php index 7718ff05a2b..f1fd1230395 100644 --- a/Cake/Network/Response.php +++ b/Cake/Network/Response.php @@ -98,7 +98,7 @@ class Response { 'cpio' => 'application/x-cpio', 'cpt' => 'application/mac-compactpro', 'csh' => 'application/x-csh', - 'csv' => array('text/csv', 'application/vnd.ms-excel', 'text/plain'), + 'csv' => array('text/csv', 'application/vnd.ms-excel'), 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dms' => 'application/octet-stream', @@ -630,12 +630,12 @@ public function statusCode($code = null) { /** * Queries & sets valid HTTP response codes & messages. * - * @param integer|array $code If $code is an integer, then the corresponding code/message is - * returned if it exists, null if it does not exist. If $code is an array, then the - * keys are used as codes and the values as messages to add to the default HTTP - * codes. The codes must be integers greater than 99 and less than 1000. Keep in - * mind that the HTTP specification outlines that status codes begin with a digit - * between 1 and 5, which defines the class of response the client is to expect. + * @param integer|array $code If $code is an integer, then the corresponding code/message is + * returned if it exists, null if it does not exist. If $code is an array, then the + * keys are used as codes and the values as messages to add to the default HTTP + * codes. The codes must be integers greater than 99 and less than 1000. Keep in + * mind that the HTTP specification outlines that status codes begin with a digit + * between 1 and 5, which defines the class of response the client is to expect. * Example: * * httpCodes(404); // returns array(404 => 'Not Found') diff --git a/Cake/Test/TestCase/Controller/Component/RequestHandlerComponentTest.php b/Cake/Test/TestCase/Controller/Component/RequestHandlerComponentTest.php index c575697202b..fc1bd455457 100644 --- a/Cake/Test/TestCase/Controller/Component/RequestHandlerComponentTest.php +++ b/Cake/Test/TestCase/Controller/Component/RequestHandlerComponentTest.php @@ -145,6 +145,21 @@ public function testInitializeContentTypeWithjQueryAccept() { $this->assertEquals('json', $this->RequestHandler->ext); } +/** + * Test that RequestHandler does not set extension to csv for text/plain mimetype + * + * @return void + */ + public function testInitializeContentTypeWithjQueryTextPlainAccept() { + $_SERVER['HTTP_ACCEPT'] = 'text/plain, */*; q=0.01'; + $event = new Event('Controller.initialize', $this->Controller); + $this->assertNull($this->RequestHandler->ext); + Router::parseExtensions('csv'); + + $this->RequestHandler->initialize($event); + $this->assertNull($this->RequestHandler->ext); + } + /** * Test that RequestHandler sets $this->ext when jQuery sends its wonky-ish headers * and the application is configured to handle multiple extensions