I'm trying to set the statusText in a response, from a module controller.



namespace modules\appmodule\controllers;

use Craft;
use craft\web\Response;

class StatusController extends \craft\web\Controller
  protected $allowAnonymous = true;

  public function actionCheck(): Response
    $response = Craft::$app->getResponse();
    $response->format = $response::FORMAT_RAW;
    $response->setStatusCode(204, 'Healthy');

    return $response;

However, the result still uses the default statusText "No Content", and still sets the format to text/html:

❯ curl  -I http://localhost:8089/actions/appmodule/status/check
HTTP/1.1 204 No Content
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: text/html; charset=UTF-8
Date: Thu, 26 Sep 2019 18:49:31 GMT
Server: nginx/1.10.3
X-Powered-By: Craft CMS
  • It is working for me on Apache... HTTP/1.1 204 Healthy – Ben Croker Oct 4 '19 at 22:02
  • Interesting! I'm on nginx, I wonder if there's some kind of setting that controls this… – Tim Kelty Nov 3 '19 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.