docs/cs-basics/network/http-status-codes.md
HTTP 状态码用于描述 HTTP 请求的结果,比如 2xx 就代表请求被成功处理。
相比于其他类别状态码来说,1xx 你平时你大概率不会碰到,所以这里直接跳过。
🐛 修正(参见:issue#2458):201 Created 状态码更准确点来说是创建一个或多个新的资源,可以参考:https://httpwg.org/specs/rfc9110.html#status.201。
这里格外提一下 204 状态码,平时学习/工作中见到的次数并不多。
The server has fulfilled the request but does not need to return an entity-body, and might want to return updated metainformation. The response MAY include new or updated metainformation in the form of entity-headers, which if present SHOULD be associated with the requested variant.
If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view.
The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.
简单来说,204 状态码描述的是我们向服务端发送 HTTP 请求之后,只关注处理结果是否成功的场景。也就是说我们需要的就是一个结果:true/false。
举个例子:你要追一个女孩子,你问女孩子:“我能追你吗?”,女孩子回答:“好!”。我们把这个女孩子当做是服务端就很好理解 204 状态码了。