Explain HTTP message in detail

Abbot's temple 2020-11-13 05:41:12
explain http message


As a web developer , Every day users Http agreement , But I always know a little . See Http RFC7230 standard , Combed http Message part .

http Message composition

start-line: Start line , Basic information describing the request or response
*( header-field CRLF ): head
[ message-body ]: news body, Data actually transmitted


Start line

The format of the starting line is
start-line = request-line( Request start line )/( Response start line )status-line

 Insert picture description here

header head  Insert picture description here

These formats are rules , Used to parse

The order
In theory, the key Order doesn't matter , But the best practice is to put the control field first , For example, when requesting Host, Responsive Date, In this way, we can find out whether we need to deal with it as soon as possible .

except Set-Cookie This key, Nothing else , If the sender sends a duplicate key, The receiver will merge it , Values are separated by commas .

Field restrictions
The protocol itself has no restrictions on each header field , But in the engineering practice, we have got some practices , There are no general restrictions , Related to the specific semantics of the field . Holistic header The size limit does not define a standard value , There are some 4K, There are some 8K.server End check to header Head over limit , On safety grounds , Don't ignore . But will throw 4XX error .

Only Host Fields are required in the request header , Nothing else .

Field Request header Response head explain
Host 1 0 Tell the server which host should handle
User-Agent 1 0 Identify browser type , Although it has been used up , Not very believable , But sometimes it can be used to customize the type
Accept 1 0 Acceptable body type mime type, such as text/html
Accept-Charset 1 0 Character set that can be received
Accept-Encoding 1 0 Acceptable encoding format
Accept-Language 1 0 Multiple languages that can be received
Content-Type 1 1 Sent body type mime type
Content-Encoding 1 1 Code sent
Content-Language 1 1 Sending language

There is a complete classification here


header It's necessary , however body You don't have to use .

body It's the content of the transmission . because Http It's the application layer protocol , So in addition to transmitting data , You also need to define the data format of the transfer . These formats are defined in header It is specified in .Content-Length Requesting or responding to body length , You have to bring this field , So that the other side can easily distinguish the message boundary , That is to say Body When does the data end . If Body Too big , Need to calculate while transmitting , You can't know the whole thing until the end of the final calculation Body The size of , It can be used at this time chunk transmission , adopt Transfer-Encoding Appoint , these two items. header key They are mutually exclusive. , Only one... Can be specified , If two are specified , The receiver takes priority Transfer-Encoding Field . Usually body When there are more data , All use chunk To transmit , High efficiency . period length, How to know that the data transmission is over , Through a length of 0 Of chunk, The corresponding block data has no content , To express body End of content .
 Insert picture description here

jetty What did you do

jetty yes web Containers , Need analysis Http Request, send out Http Response. What did you do next time

Official account 【 Abbot's temple 】, The first time to receive an update of the article , Start the road of technical cultivation with the abbot
 Insert picture description here

Reference resources


本文为[Abbot's temple]所创,转载请带上原文链接,感谢

  1. css单位
  2. CSS unit
  3. 前端验证集合
  4. Front end validation collection
  5. Front end learning (4) -- response line, response head, response body
  6. Lesson 27: using time measuring tools to explore available spare time
  7. CSS 单位
  8. CSS unit
  9. 前端工具集合
  10. Front end Tools Collection
  11. Introduction to HTTP message format
  12. Introduction to new features of HTML5
  13. Common instructions for Vue
  14. Introduction of bootstrap Blazer component library
  15. HTML5 速览
  16. HTML5 quick view
  17. HTML表格自动排序
  18. For less than $1700, create a private cloud with openstack
  19. Basic learning of JavaScript (1)
  20. Front end learning about nginx
  21. Front end interview of HTTP protocol things!
  22. 前端编程之路一一HTML标签分类
  23. Front end Programming: HTML tag classification
  24. ColSpan and rowspan merging cells of HTML form elements
  25. JavaScript 日期时间格式化
  26. JavaScript date time formatting
  27. Classification of front end interview questions - html2
  28. One time nginx proxy_ set_ Analysis and extension of header fault
  29. Crawler series | 2, HTTP request and response, write crawler these contents must master
  30. CSS block elements
  31. HTML5 form detailed tutorial
  32. HTML5 form detailed tutorial
  33. HTML5新增的元素表
  34. New element table in HTML5
  35. 3D轮播插件vue-carousel-3d非官方最全文档
  36. 3D carousel plug-in vue-carousel-3d
  37. Uniapp (Vue general) integrates Tencent location service SDK -- multi platform small program general
  38. Slowhttptest slow attack tool use details
  39. HTML summary (2)
  40. Overview of CSS3
  41. HTTP protocol for Wireshark packet capture analysis
  42. Front end abnormal monitoring system
  43. 免费网站部署和免费数据库Serverless云存储资源汇总整理
  44. Free website deployment and collection of free database serverless cloud storage resources
  45. Vux form -- a form solution of base vux
  46. 可以直接用于HTML中的特殊字符表 unicode字符集
  47. Can be directly used in HTML special character table Unicode character set
  48. Detailed explanation of HTTP protocol
  49. HTTP request header and request response header
  50. CSS background深度解析
  51. Python web/HTML GUI
  52. Front end standard 2: HTML you know and don't know
  53. Some HTML tags
  54. Introduction to JavaScript Foundation Series (1)
  55. JQuery easyUI DataGrid performance optimization topic
  56. CSS naming and writing specification
  57. [HTTP column introduction] HTTP learning and cognition