title: Sending correct JSON content type for CakePHP
body: <p>In my CakePHP app I return JSON and exit for certain requests. An example of this would be trying to access the API for a login as a GET request:</p>
  
  <pre><code>header('Content-Type: application/json');
  echo json_encode(array('message'=&gt;'GET request not allowed!'));
  exit;
  </code></pre>
  
  <p>However I am having to prefix the echo with the content type in order for it to be sent as JSON. Otherwise my code at the other end interprets it different.</p>
  
  <p>Any ideas on how to get around this? Or at least improve it.</p>
  
  <p><strong>Update: Cake version 2.3.0</strong></p>