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

<p>E.g.:</p>

<pre><code>&lt;?php

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-&gt;getResponse();
    $response-&gt;format = $response::FORMAT_RAW;
    $response-&gt;setStatusCode(204, 'Healthy');

    return $response;
  }
}
</code></pre>

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

<pre><code>❯ 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
</code></pre>

CC BY-SA 4.0
2019-10-04T22:02:43.380Z
It is working for me on Apache... `HTTP/1.1 204 Healthy`
Ben Croker
CC BY-SA 4.0
2019-11-03T13:14:43.307Z
Interesting! I'm on nginx, I wonder if there's some kind of setting that controls this…
Tim Kelty
<plugin-development><controller><modules><headers>
How can I override the Response status text from a controller?
# How can I override the Response status text from a controller?

(Asked by: username_0 on 2019-09-26)

I'm trying to set the statusText in a response, from a module controller.
E.g.:
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

**Tags:** plugin-development, controller, modules, headers

> **Comments:**
> **username_1**: It is working for me on Apache... `HTTP/1.1 204 Healthy`  
> **username_0**: Interesting! I'm on nginx, I wonder if there's some kind of setting that controls this…  

---

## 0 answers

