[one knowledge point a day] - HTTP status code

Shuangmu forest 2021-01-21 11:37:54
knowledge point day http status


Status code

brief introduction

  • HTTP The status code is responsible for representing the client HTTP The return result of the request 、 Mark whether the server-side processing is normal 、 Notification of errors, etc

Role and category

  • effect : The status code tells the result of the request returned from the server

  • Category of status code
  • Be careful : Just follow the definition of the status code category , Even if it changes RFC2616 The status code defined in , Or the server can create its own status code

Specific meaning

2XX success

  • meaning :2XX The result of the response shows that the request was processed normally
  • type :
    • 200 OK: Indicates that the request from the client is processed normally on the server side
    • Status code 200 The appended drawings
    • 204 No Content: The status code represents that the request received by the server has been successfully processed , But the main body of the entity is not included in the returned response message , Nor is it allowed to return the body of any entity
    • Status code 204 The appended drawings
    • 206 Partial Content: Indicates that the client has made a range request , And the server successfully executed this part of GET request , The response message contains the message from Content-Range Specify the scope of entity content
    • Status code 206 The appended drawings

3XX Redirect

  • meaning :3XX The response results indicate that the browser needs to perform some special processing to properly handle the request
  • type :
    • 301 Moved Permanently: Permanent redirection , Indicates that the requested resource has been assigned a new URI, In the future, we should use what resources refer to now URI
    • Status code 301 The appended drawings
    • 302 Found: Temporary redirections , Indicates that the requested resource has been assigned a new URI, Hope users ( This time ) Can use the new URI visit
    • Status code 302 The appended drawings
    • 301 And 302 difference :
      • 301 The resource represented by the status code is moved permanently
      • 302 The resource represented by the status code is not permanently moved , It's just temporary
    • 303 See Other: The status code indicates that there is another URI, You should use GET Method to get the requested resource
    • Status code 303 The appended drawings
    • difference :303 Status codes and 302 Found Status codes have the same function , but 303 The status code clearly indicates that the client should adopt GET Method to get resources , With this 302 The status code is different
    • Be careful : When 301、 302、 303 When the response status code returns , Almost all browsers will put POST Change to GET, And delete the main body in the request message , Then the request will be sent again automatically .301、 302 The standard is to prohibit POST The method is changed to GET Methodical , But in practice, people do it
    • 304 Not Modified: Indicates that when the client sends a conditional request , The server side allows requests to access resources , But not meet the conditions . 304 When the status code returns , Does not contain the body part of any response . 304 Although it is divided into 3XX In category , But it has nothing to do with redirection
    • Status code 304 The appended drawings
    • Conditional request : A conditional request is to adopt GET Method contains If-Match,If-Modified-Since,If-None-Match,If-Range,If-Unmodified-Since Any of the first
    • 307 Temporary Redirect: Temporary redirection , Meaning as follows 302,307 Will follow browser standards , Not from POST become GET( Even though 302 Standard prohibition POST Transform into GET, But in practice, we do not abide by )

4XX Client error

  • meaning :4XX The result of the response shows that the client is the cause of the error
  • type :
    • 400 Bad Request : Indicates that there is a syntax error in the request message . When a mistake happens , You need to modify the content of the request and send the request again . in addition , Browsers will look like 200 OK Treat the status code as well
    • Status code 400 The appended drawings
    • 401 Unauthorized: Indicates that the request sent needs to be passed HTTP authentication (BASIC authentication 、DIGEST authentication ) Authentication information . In addition, if it has been done before 1 Requests , It means to use User authentication failed
    • Status code 401 The appended drawings
    • Be careful : Return contains 401 The response to must contain a... For the requested resource WWWAuthenticate The first one is for questioning (challenge) User information . When the browser first receives 401 Respond to , The dialog window for authentication will pop up
    • 403 Forbidden: Indicates that access to the requested resource has been denied by the server . There is no need for the server to give a detailed reason for rejection , But if you want to explain , It can be in the main body of the entity 6 Describe the cause , So that users can see
    • Status code 403 The appended drawings
    • Be careful : Unauthorized access to the file system , There's something wrong with access rights ( Never authorized source IP Address trying to access ) It's possible that 403 Why
    • 404 Not Found: Indicates that the requested resource could not be found on the server . besides , It can also be used when the server rejects the request and does not want to explain the reason
    • Status code 404 The appended drawings
    • Be careful : The status code indicates that the requested resource could not be found on the server . besides , It can also be used when the server rejects the request and does not want to explain the reason

5XX Server error

  • meaning :5XX The response result of the server indicates that the server itself has an error
  • type :
    • 500 Internal Server Error: Indicates that an error occurred on the server side while executing the request . It could be Web Applications exist bug Or some temporary failure
    • Status code 500 The appended drawings
    • 503 Service Unavailable: Indicates that the server is temporarily overloaded or under shutdown maintenance , Can't process the request right now . If you know in advance how long it will take to get rid of the above situation , Best write RetryAfter The first field is returned to the client
    • Status code 503 The appended drawings

summary

  • In daily use , There are often inconsistencies between status code and status . Many returned status code responses are wrong , But users may not be aware of this . Try to follow the standard when using , To be clear at a glance
版权声明
本文为[Shuangmu forest]所创,转载请带上原文链接,感谢
https://javamana.com/2021/01/20210121113701191R.html

  1. 【计算机网络 12(1),尚学堂马士兵Java视频教程
  2. 【程序猿历程,史上最全的Java面试题集锦在这里
  3. 【程序猿历程(1),Javaweb视频教程百度云
  4. Notes on MySQL 45 lectures (1-7)
  5. [computer network 12 (1), Shang Xuetang Ma soldier java video tutorial
  6. The most complete collection of Java interview questions in history is here
  7. [process of program ape (1), JavaWeb video tutorial, baidu cloud
  8. Notes on MySQL 45 lectures (1-7)
  9. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  10. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  11. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  12. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  13. 【递归,Java传智播客笔记
  14. [recursion, Java intelligence podcast notes
  15. [adhere to painting for 386 days] the beginning of spring of 24 solar terms
  16. K8S系列第八篇(Service、EndPoints以及高可用kubeadm部署)
  17. K8s Series Part 8 (service, endpoints and high availability kubeadm deployment)
  18. 【重识 HTML (3),350道Java面试真题分享
  19. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  20. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  21. [re recognize HTML (3) and share 350 real Java interview questions
  22. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  23. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  24. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  25. RPC 1: how to develop RPC framework from scratch
  26. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  27. RPC 1: how to develop RPC framework from scratch
  28. 一次性捋清楚吧,对乱糟糟的,Spring事务扩展机制
  29. 一文彻底弄懂如何选择抽象类还是接口,连续四年百度Java岗必问面试题
  30. Redis常用命令
  31. 一双拖鞋引发的血案,狂神说Java系列笔记
  32. 一、mysql基础安装
  33. 一位程序员的独白:尽管我一生坎坷,Java框架面试基础
  34. Clear it all at once. For the messy, spring transaction extension mechanism
  35. A thorough understanding of how to choose abstract classes or interfaces, baidu Java post must ask interview questions for four consecutive years
  36. Redis common commands
  37. A pair of slippers triggered the murder, crazy God said java series notes
  38. 1、 MySQL basic installation
  39. Monologue of a programmer: despite my ups and downs in my life, Java framework is the foundation of interview
  40. 【大厂面试】三面三问Spring循环依赖,请一定要把这篇看完(建议收藏)
  41. 一线互联网企业中,springboot入门项目
  42. 一篇文带你入门SSM框架Spring开发,帮你快速拿Offer
  43. 【面试资料】Java全集、微服务、大数据、数据结构与算法、机器学习知识最全总结,283页pdf
  44. 【leetcode刷题】24.数组中重复的数字——Java版
  45. 【leetcode刷题】23.对称二叉树——Java版
  46. 【leetcode刷题】22.二叉树的中序遍历——Java版
  47. 【leetcode刷题】21.三数之和——Java版
  48. 【leetcode刷题】20.最长回文子串——Java版
  49. 【leetcode刷题】19.回文链表——Java版
  50. 【leetcode刷题】18.反转链表——Java版
  51. 【leetcode刷题】17.相交链表——Java&python版
  52. 【leetcode刷题】16.环形链表——Java版
  53. 【leetcode刷题】15.汉明距离——Java版
  54. 【leetcode刷题】14.找到所有数组中消失的数字——Java版
  55. 【leetcode刷题】13.比特位计数——Java版
  56. oracle控制用户权限命令
  57. 三年Java开发,继阿里,鲁班二期Java架构师
  58. Oracle必须要启动的服务
  59. 万字长文!深入剖析HashMap,Java基础笔试题大全带答案
  60. 一问Kafka就心慌?我却凭着这份,图灵学院vip课程百度云