带条件更新的 HTTP 状态码
Http status code for updates with conditions
早上好:
我的 api 有一个资源,如果满足条件,它会更新我的数据库记录,当满足条件并更新记录时,我 return HTTP 状态代码 200,但是我不知道不满足条件时的 Http 状态代码 return,因为它不可能是 400 错误,因为请求格式正确
非常感谢您的回复
即使请求格式正确,您也可以使用 4xx(为什么您不这么认为?):
The 4xx (Client Error) class of status code indicates that the client
seems to have erred. Except when responding to a HEAD request, the
server SHOULD send a representation containing an explanation of the
error situation, and whether it is a temporary or permanent condition.
These status codes are applicable to any request method. User agents
SHOULD display any included representation to the user.
(参见 https://greenbytes.de/tech/webdav/rfc7231.html#status.4xx)
请求失败时返回 2xx 根本没有任何意义。
早上好:
我的 api 有一个资源,如果满足条件,它会更新我的数据库记录,当满足条件并更新记录时,我 return HTTP 状态代码 200,但是我不知道不满足条件时的 Http 状态代码 return,因为它不可能是 400 错误,因为请求格式正确
非常感谢您的回复
即使请求格式正确,您也可以使用 4xx(为什么您不这么认为?):
The 4xx (Client Error) class of status code indicates that the client seems to have erred. Except when responding to a HEAD request, the server SHOULD send a representation containing an explanation of the error situation, and whether it is a temporary or permanent condition. These status codes are applicable to any request method. User agents SHOULD display any included representation to the user.
(参见 https://greenbytes.de/tech/webdav/rfc7231.html#status.4xx)
请求失败时返回 2xx 根本没有任何意义。