HTTP Get with 204 No Content: Is that normal

后端 未结 5 693
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 10:11

Is it a normal occurrence for an HTTP GET Request to have a response with status code 204 - No Content? Like, is this semantically correct concerni

5条回答
  •  悲&欢浪女
    2021-01-30 10:45

    The POST/GET with 204 seems fine in the first sight and will also work.

    Documentation says, 2xx -- This class of status codes indicates the action requested by the client was received, understood, accepted, and processed successfully. whereas 4xx -- The 4xx class of status code is intended for situations in which the client seems to have erred.

    Since, the request was successfully received, understood and processed on server. The result was that the resource was not found. So, in this case this was not an error on the client side or the client has not erred.

    Hence this should be a series 2xx code and not 4xx. Sending 204 (No Content) in this case will be better than a 404 or 410 response.

提交回复
热议问题