202 Accepted 是对 http 补丁的可接受响应吗?

Is 202 Accepted an acceptable response to an http patch?

我需要对资源进行异步更新。是否有关于 202 Accepted 是否是对 PATCH 的适当响应的明确声明?

官方文档here,从未提及202,并且似乎假设由于PATCH而导致的资源更改是同步进行的,但它从未做出明确的声明。

PATCH 操作的合适示意图是什么?

我不明白为什么返回 202 是错误的。虽然没有明确提及使用 202,但规范确实在示例中暗示了它。

Successful PATCH response to existing text file:

HTTP/1.1 204 No Content Content-Location: /file.txt ETag: "e0023aa4f"

The 204 response code is used because the response does not carry a message body (which a response with the 200 code would have). Note
that other success codes could be used as well.

202 是一个成功代码,它的定义并不禁止它在 PATCH.

中使用

10.2.3 202 Accepted

The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place. There is no facility for re-sending a status code from an asynchronous operation such as this.

The 202 response is intentionally non-committal. Its purpose is to allow a server to accept a request for some other process (perhaps a batch-oriented process that is only run once per day) without requiring that the user agent's connection to the server persist until the process is completed. The entity returned with this response SHOULD include an indication of the request's current status and either a pointer to a status monitor or some estimate of when the user can expect the request to be fulfilled.

只要您以原子方式进行修补并且异步请求不会使资源处于半修补状态,这应该是好的。