👉欢迎准备 Java 面试以及学习 Java 的同学加入我的知识星球,干货很多!收费虽然是白菜价,但星球里的内容或许比你参加上万的培训班质量还要高。 👉《Java 面试指北》持续更新完善中!这是一份教你如何更高效地准备面试的小册,涵盖常见八股文(系统设计、常见框架、分布式、高并发 ......)、优质面经等内容。
你好,我是 Guide。分享一道群友面试字节遇到的 HTTP 状态码相关的面试真题:”HTTP 常见的状态码有哪些?“。
下面是正文。
HTTP 状态码用于描述 HTTP 请求的结果,比如2xx 就代表请求被成功处理。
相比于其他类别状态码来说,1xx 你平时你大概率不会碰到,所以这里直接跳过。
这里格外提一下 204 状态码,平时学习/工作中见到的次数并不多。
HTTP RFC 2616对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 状态码了。
参考
马上秋招就来了,最近一直在抽时间更新面试真题(原创不易,有帮助的话,点赞分享就是对 Guide 最大的鼓励):
·········· END ··············
欢迎加入我的知识星球获取更多面试干货,《Java 面试指北》持续更新完善中!
近期文章精选 :
走近作者 :
如果本文对你有帮助的话,欢迎 点赞&在看&分享 ,这对我继续分享&创作优质文章非常重要。非常感谢!