slimphp / Slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
http://slimframework.com
MIT License
11.98k stars 1.95k forks source link

add support for 419 / Authentication Timeout HTTP response status code #1675

Closed thescientist13 closed 8 years ago

thescientist13 commented 8 years ago

I was working with Slim 2.8.2 and noticed that trying to set a 419 response $slim->response->setBody(419);

would return a 200 to the client (in this case cURL via CLI).

Looking at the latest set of codes, 419 is not there https://github.com/slimphp/Slim/blob/3.x/Slim/Http/Response.php

Didn't see anything related in the open or closed issues list. Is this something I could submit a PR for? Understood it is not part of the RFC, but I have been seeing it used I would like to be able to support it.

Reference: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error

mathmarques commented 8 years ago

I don't think we need to add if it's not part of the RFC.

If you're talking about Slim 3 you can use:

$response = $response->withStatus(419, 'Authentication Timeout');
thescientist13 commented 8 years ago

I'm actually on 2.8.2, is there a way with 2.x to do the same?

silentworks commented 8 years ago

Not sure why you are setting the status code as the body, you need to set the status code as a status code.

$app->response->setStatus(419);

https://github.com/slimphp/Slim/blob/2.x/Slim/Http/Response.php#L156