我有一个 RESTful 网络服务,需要接受最终用户许可协议(protocol) (EULA) 才能使用。
如果 EULA(尚未)被接受,哪个 HTTP 状态代码最适合网络服务返回?
目前我看到以下可能性(我目前最喜欢的粗体):
- 403 禁止
- 412 前提条件失败
- 417 期望失败
- 423锁定
- 428 需要先决条件#
- 451 因法律原因无法使用
最佳答案
根据 CodeCaster 的建议我去了 w3.org 并查看了 definitions of HTTP Status Codes in RFC2616 .我发现状态码 403 最合适:
10.4.4 403 Forbidden
The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found) can be used instead.
关于rest - "EULA not accepted"的 HTTP 状态代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34720726/