I need to remove the Content-Length header on the response object when status code === 204
I’ve tried the following
$response = $response->withoutHeader(‘Content-Length’);
return $response->withStatus(204);
Content-Length header is always 20, no matter what.
Anyone can help?
SVL
June 14, 2017, 6:15pm
2
Maybe you need to set addContentLengthHeader to false instead:
$config = [
'settings' => [
'addContentLengthHeader' => false,
]
];
$app = new Slim\App($config);
I’ve just created a dummy project, using the Skelleton app which as to false by default
composer create-project slim/slim-skeleton testEmpty
I’ve added a route
$app->get('/empty', function ($request, $response, $args) {
return $response->withStatus(204);
});
And the Content-Length header is present with a 0 value
This is probably getting set by your web server.
Yes. This is what I just found out. Removing the Content-Encoding (mod deflate with Apache) makes the Content-Length value as 0 instead or 20 which is already good.
Not a Slim issue.
1 Like