How to return 419 HTTP status in a Symfony 2 Response object

I am currently working on the HTTP API in Symfony 2, for which I have executed the OAuth2 password credentials for authentication. During authentication, the client received two tokens, one access and one update token.

Somehow I need to tell the client that the access token is no longer valid and that the update token should be used to get a new access token.

I looked at the list of HTTP codes [1], and it seems to me that the 418 authentication status is the most suitable. However, when I use this in an object Response, I actually get the status 500:

return new Response("OK", 419);

Results:

$ curl -X GET http://local.api

< HTTP/1.1 500 Internal Server Error
< Date: Thu, 23 Jan 2014 21:34:39 GMT
* Server Apache/2.4.6 (Ubuntu) is not blacklisted
< Server: Apache/2.4.6 (Ubuntu)
< X-Powered-By: PHP/5.5.3-1ubuntu2.1
< Cache-Control: no-cache
< X-Debug-Token: b7c386
< X-Debug-Token-Link: /app_dev.php/_profiler/b7c386
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8

, Response, , ( , ), Response , 419.

511 Network Authentication Required, 419. ?

[1] http://en.wikipedia.org/wiki/List_of_HTTP_status_codes

+4
1

, InvalidArgumentException, . ( Symfony)

-1

Source: https://habr.com/ru/post/1523430/


All Articles