Is it wrong to return 202 “Accepted” in response to HTTP GET?

后端 未结 4 1403
遇见更好的自我
遇见更好的自我 2020-12-02 16:24

I have a set of resources whose representations are lazily created. The computation to construct these representations can take anywhere from a few milliseconds to a few hou

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 17:02

    If it's for a well-defined and -documented API, 202 sounds exactly right for what's happening.

    If it's for the public Internet, I would be too worried about client compatibility. I've seen so many if (status == 200) hard-coded.... In that case, I would return a 200.

    Also, the RFC makes no indication that using 202 for a GET request is wrong, while it makes clear distinctions in other code descriptions (e.g. 200).

    The request has been accepted for processing, but the processing has not been completed.

提交回复
热议问题