This paper is about 《 Thirty thousand long articles 50+ Interesting pictures take you to understand web Internal mental skill of programming 》 The second chapter .
2、 First time to know HTTP/1.1
Now let's briefly introduce HTTP/1.1 Advantages and disadvantages , So that we can have an understanding of it , And then we can learn more about .
Precisely because HTTP There are few restrictions in the specification , Tell you what you can do , But it won't tell you what rules can't do , therefore , It's easy to expand , That's why from HTTP/0.9 Be born , Keep expanding and upgrading , The reason to add more features .
2.2、 Transmission reliability
Because the bottom layer is based on TCP Agreed , So I inherited it TCP Reliability of transmission data , Mainly reflected in 1：
- The sequential transmission of data ;
- Packet loss retransmission , Make sure it's reliable ;
- Connection maintenance ;
- flow control , Keep it stable ;
- Congestion control , Adjust in time , To maximize the normal transmission .
2.3、 Based on the request response mode
Only one party initiates the connection and request first , The receiver can respond .HTTP It's based on this one question one answer mode . If the client does not request , The server will not take care of the client .
Although behind HTTP/2 There is a server push 2, But it's also a push for specific resources , It's not that the server can push whatever it wants .
2.4、 No state
Having a state means that a certain state must be identified to track the state , It's like TCP State machine ,TCP The request header has a specific status identification bit to maintain the status of the connection .
HTTP There's no place to record status , That is to say, in an interactive scenario ,HTTP No memory . This leads to problems like this ：
- The same user visits a website many times , Need to read repeatedly for authentication .
Even if it's turned on keep-alive Mechanism , Also only TCP The maintenance of the level of connection , about HTTP Layer , It seems to be in a state of no state .
We can't ask users to input their account and password for authentication every time , That's why Cookie and Session, by HTTP Make up for the problem of state storage .
2.5、 Plaintext transmission , unsafe
We use the bag grabbing tool to grab HTTP/1.1 My bag , You can see the contents in the request header and body with the naked eye , So when a user logs in to request , The password of the transmitted account can be captured as follows .
We know , The link of data request in the network is very long , As long as any link catches your bag , Your data is leaked . That's why we're launching HTTPS Why .
2.6、 Poor performance ( request - The reply )
Because of the request response mechanism , You need to send a large request header every time , The efficiency is poor .
in addition ,HTTP/1.1 Based on the request - Response mode , In the application layer, there is the problem of queue head blocking , also TCP There will also be layers TCP The team head block problem , This leads to poor performance , We need to optimize the network request through various tricks .
Efficiency is what drives HTTP/2、HTTP/3 One of the reasons for its birth .
This paper is about arthinking Based on relevant technical data and official documents , Make sure the content is accurate , If you find something wrong , Please raise your hand to help correct , grateful .
If you feel that you have gained from reading this article , Can follow my account , Or like it , It's not easy to code words , Your support is my greatest motivation for writing , Thank you again for ！
In order to collect the related articles , Convenient for subsequent reference , Here I create a Github Warehouse , Collect the published articles according to their categories , Interested friends can Star To follow up ：
Follow my blog
IT house (itzhai.com) The official account
Java Architecture talks , Get the latest articles in time . I will continue to update back-end technologies , involve JVM、Java Basics 、 Architecture design 、 Network programming 、 data structure 、 database 、 Algorithm 、 Concurrent programming 、 Distributed system and other related content .
- Xie Xiren . computer network ( The first 6 edition ). Electronic industry press .
- TCP/IP Detailed explanation volume 1： agreement （ The book first 2 edition ）. Mechanical industry press .
- UNIX Network programming volume 1： Socket networking API. People's post and Telecommunications Press
- HTTP Authoritative guide . People's post and Telecommunications Press
- HTTP/2 Basic course . People's post and Telecommunications Press
- Liu chao . Talk about network protocol . Geek time
- Luo Jianfeng . perspective HTTP agreement . Geek time
This article is published in my blog
IT house (itzhai.com)and
official account (Java Architecture talks )
author ： arthinking | official account ：Java Architecture talks
Blog links ： https://www.itzhai.com/articl...
Copyright notice ： The copyright belongs to the author , Shall not be reproduced without permission , Infringement must be investigated ！ Please contact the author with the official account. .
- Twenty thousand words 50+ Zhang QITU takes you to understand the internal mental skill of network programming -TCP characteristic . Retrieved from https://www.itzhai.com/network/comprehend-the-underlying-principles-of-network-programming.html#4-2-2%E3%80%81TCP%E7%89%B9%E7%82%B9
- Technical dry cargo ：HTTP/2 Server push (Server Push) Best practices . Retrieved from https://www.infoq.cn/article/qYdN85t4G4dL4vBAe3N2