To know the HTTP
Daily use process
Let’s start with a picture
In the course of our daily visit to the website. It actually accesses the same IP address. What is the domain name? “, an alternate name. Convenient for our users to visit the website
We are in the process of sending a request. The rules to be followed (i.e., protocols). HTTP protocol
Why follow the rules (agreements)?
For example, it’s like making a phone call. You speak Chinese. They speak English. You must not be able to understand each other. Therefore, we must stipulate a uniform dialogue format. Also known as rules or protocols
The next. This brings us to the concept of HTTP
What is the HTTP
HTTP (Hypertext Transfer Protocol) is a communication Protocol that allows the Transfer of ** HTML ** documents from a Web server to a client’s browser.
One more official concept
HTTP is an object-oriented protocol belonging to the application layer. Because of its simple and fast way, it is suitable for distributed hypermedia information system. It was put forward in 1990. After several years of use and development, it has been constantly improved and expanded.
We can break it down
-
hypertext
In the early days of the Internet, the information we entered could only exist as text. However, with the development of the Internet, we are not satisfied with only text transmission, but also want to transmit pictures, audio and video, and even click on the text or picture to jump to a hyperlink. At this time, the semantics and scope of the text are expanded. That’s why it’s called hypertext
-
transmission
What is transmission? The two computers communicate with each other
This involves computer network communication. The communication modes between the end systems at the edge of the network can be divided into C/S(client-server mode) and P2P (peer-to-peer connection mode). Here we mainly talk about C/S(client-server approach)
Often, the party sending the request is referred to as Clint **, or the requester. The server that receives the request is called the server (serve). The relationship between them, as shown above, is between the browser and the Web server
-
agreement
We have explained this once above. Let me be a little bit more specific
Network protocols are the norms for transmitting and managing information in networks (including the Internet). Just as people need to follow certain rules to communicate with each other, computers need to follow certain rules to communicate with each other, these rules are called network protocols
-
To sum up the above points. So what is HTTP? .
HTTP is a convention and specification for the transfer of hypertext data between two computers communicating
Extension, what is the Web
The Web is hypertext and HTTP based, global. Dynamic interactive, cross-platform distributed graphic information system, a network service built on the Internet that provides a graphical, easy-to-access interface for visitors to find and browse information on the Internet
Internet is different from Internet. The former refers to the Internet, instead of a network of interconnected computer networks.
The latter stands for the Internet, instead of the world’s largest, open, specialized computer network
Understand HTTP through TCP/IP
TCP/IP you’ve probably heard of it, but TCP/IP is often called the protocol family because it’s not just TCP and IP. It is a collection of protocols associated with the Internet. Its most important feature is hierarchical management. HTTP belongs to the TCP/IP protocol family
TCP/IP protocol family layer
It is divided into 4 layers, from top to bottom
-
The application layer
The application layer of the Internet includes many protocols, such as HTTP, which supports the World Wide Web, EMAIL transfer protocol SMTP, FTP, DNS, and domain name resolution. The data units that the application layer interacts with are called packets.
The task is to complete a specific network application through the interaction of application processes
Protocols define rules for application processes to communicate and interact
-
The transport layer
Task: To provide a common data transfer service for communication between processes on two hosts
The following two protocols are used
TCP
Transmission control protocol.Connection-oriented, reliable data transfer service. Transmission unit:Message segmentUDP
User datagram protocol.Connectionless, best effort data transfer service (data reliability is not guaranteed). Transmission unit:User datagram
-
The network layer
Task:
- Responsible for providing communication services to different hosts on the packet switched network
- Select an appropriate route. It’s a packet passed down through the transport layer that can find the host through the router
Packet, the smallest unit of network transmission
The network layer of the Internet is also called the Internet layer or IP layer.
Reason: The main network layer protocols on the Internet are the connectionless Internet Protocol (IP) and many routing protocols
-
Network interface layer
In essence. The last layer, the network interface layer, is functionally indistinguishable from normal communication links
Task: Assemble IP datagrams from the network layer into frames and transmit the frames over the link between two adjacent nodes. Each frame contains data and necessary control information (synchronization information, etc.)
The relationship is shown in the figure
Extend OSI and five layer protocol architecture
Compare that to the upper layers. Much more
-
The physical layer
The role of the physical layer is to transport the bits in the frame from one node to another. The protocols of the physical layer still use link layer protocols, which are related to the actual physical transport medium
-
The session layer
Provides demarcation and synchronization functions for data exchange, including the establishment of checkpoints and recovery schemes.
-
The presentation layer
It mainly includes data compression and encryption as well as data description, which enables applications to avoid the problem of computer internal storage format
HTTP transfer process
The literal explanation is. When sending data, the sender needs to add some header information (control information) of this layer every time the data passes (the first physical layer does not add header information).
The receiver goes through one layer at a time. It will erase all the corresponding headers
The OSI reference model refers to units of data transmitted between peer levels as the layer’s protocol data unit (PDU)
Pass the data directly to the other side through the dotted line. This is called communication between peers
Transport layer – three handshakes
You must establish a connection before using TCP to communicate. Data can be transferred when the two parties establish a connection. TCP adopts the three-way handshake policy
Photo from Baidu. Infringement to delete
First handshake: When establishing a connection, the client sends a SYN packet (SYN = J) to the server and enters the SYN_SEND state, waiting for confirmation from the server.
Second handshake: After receiving a SYN packet, the server must acknowledge the client’s SYN (ACK = J +1) and send a SYN packet (ACK = K). In this case, the server enters the SYN_RECV state. Third handshake: After receiving the SYN+ACK packet from the server, the client sends an ACK packet (ACK = K +1) to the server. After the packet is sent, the client and the server enter the ESTABLISHED state to complete the three-way handshake.
Data transfer can then begin
Why three handshakes?
Ensure that the sending and receiving capabilities of the client and server are normal
DNS Domain name Resolution
Usually we visit a website using a host name or domain name. That’s because domain names are easier to remember than IP addresses (a set of pure numbers). But TCP/IP uses IP addresses for access, so there must be a mechanism or service to convert domain names to IP addresses. The DNS service provides the resolution service between domain names and IP addresses.
See the illustration for the first picture of daily use
To know the HTTP
Through the above introduction, we have a certain understanding of the HTTP protocol. Next, we’ll go into more details
HTTP Protocol Features
-
support
C/S
Client/server modeHTTP is a member of the TCP/IP protocol family and can be used in client/client mode
In client/server mode, the client sends a request to the server, and the server responds to the request and provides corresponding services
As is shown in
-
Simple and quick
When a customer requests services to a server, it only needs to send request methods and path request methods commonly used GET, HEAD and POST. Each method determines the type of contact between the client and the server. Because HTTP protocol is simple, the program size of HTTP server is small, so the communication speed is fast
-
flexible
HTTP allows the transfer of data objects of any Type, controlled and marked by the Content-type (onten-type is the identifier used in the HTTP package to indicate the Content Type)
-
There is no connection
Meaning: Only one request is processed per connection
After the server processes the customer’s request and receives the reply from the customer, the server disconnects from the customer. This method saves transmission time
-
stateless
The HTTP protocol is stateless. Stateless means that the protocol has no memory for transaction processing. The lack of state means that if the previous information is needed for subsequent processing, it must be retransmitted, which can result in an increase in the amount of data transferred per connection. The server takes longer to process. Conversely, smaller data means faster processing time
To solve this. We can use cookie Session to solve this problem
The URI and URL
So let me put a picture here
A Uniform Resource Identifier (URI) is a Uniform Resource Identifier (URI) that uniquely identifies resources on the Internet.
The full name of URL is Uniform Resource Locator. The Chinese name is Uniform Resource Locator, which is actually a subset of URI. In addition to identifying a resource, it provides a primary access mechanism for locating that resource
URN is an Internet Resource with a Name.
The biggest difference between urls and URIs is their access mechanism
Maybe the relationship is not clear. We use the wikipedia explanation
URI
Can be divided intoURL
.URN
Or something that has both Locators and Names featuresURN
It works like a person’s name,URL
It’s like a person’s address- In other words :URN identifies something, and ∪RL provides the means to find it
Analysis of HTTP packet structure
The HTTP protocol mainly consists of three parts:
Start line
: Describes basic information about a request or response.Header
Use:key-value
Form specifies the message in more detail;Entity
: Indicates the actual data to be transmitted. It may be binary data, such as pictures and videos, rather than plain text.
Four types of header summary
-
Universal header
-
Request header
-
Response header
-
Entity header
The request message
In the beginning, we said there are three parts (opening line, header, and message style).
Here we introduce some common headers
-
ACCEPT: indicates the media type accepted by the browser
ACCEPT:*/* means to ACCEPT all types, if we cannot return the request type we want. 406 error (Non Acceptable) is reported
-
Accept-encoding: indicates the received Encoding mode. The compression mode is usually specified. Whether compression is supported and what compression methods are supported (commonly gzip, Deflate)
-
Accept-language: indicates the Language received by the browser
For example:
Accept-Language: zh-cn, zh; Q = 0.7, en - us, en. Q = 0.3
Q represents the weight value. The higher the weight value, the higher the priority return (maximum 1, and do not add to 1)
-
Connection
keep-alive
When a web page is opened, the TCP connection between the client and the server for the transmission of HTTP data is not closed. If the client accesses the web page on the server again, the established connection is used
close
This will close the connection and send the request again
-
Host:
It is used to specify the host and port number of the requested resource
-
Referer.
It came from that page. The server can get some useful information from this
-
User-Agent
Client operating system, browser name version
-
Content-Type
The media type of the newspaper object. Summarized below
Request method and resolution
HTTP request methods generally fall into eight categories, which are
-
GET Gets the resource. The GET method is used to request access to the resource identified by the URI. The specified resource is parsed by the server and the response content is returned.
If the requested resource is text, return it as is;
-
POST transmits entity information, although GET method can also transmit subject information, but it is easy to distinguish, we generally do not GET to transmit entity information, but use POST to transmit entity information.
-
PUT Transfers files. The PUT method is used to transfer files. Similar to file uploading over FTP, the file content must be contained in the body of the request packet and saved to the location specified by the request URI.
-
HEAD gets the response HEAD. The HEAD method is the same as GET, but does not return the body of the message. Used to verify the validity of the URI and the date and time of resource updates.
-
DELETE Deletes a file. The DELETE method is used to DELETE a file. It is the opposite of PUT. The DELETE method deletes the specified resource based on the request URI.
-
OPTIONS asks for supported methods. The OPTIONS method is used to query supported methods for the resource specified by the request URI.
-
TRACE TRACE path, and the request received by the server is displayed. Mainly used for testing or diagnosis.
-
CONNECT Requires a tunnel protocol to CONNECT the proxy and establish a tunnel when communicating with the proxy server to implement TCP communication using the tunnel protocol. Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols are used to encrypt communication content and then transmit it through network tunnels.
The most commonly used methods are GET methods and POST methods, and other methods can be understood temporarily.
The response message
Response headers
HTTP / 1.1 200 0k
Server: aChen
Date: Sat, 10 Aug 2020 03: 31: 25GMT
Cache-control: no-cache
Expires: 0
Content-length: 413
Content-type: text/html; charset=ISO-8859-1
Date: Sat, 10 Aug 2020 03: 31: 25 GMT
Expires: 5S
Copy the code
Response body
<html>
<title>test</title>
<body>Returns the content of your response</body>
</html>
Copy the code
Status code
A three-digit code used to indicate the status of a web server hypertext Transfer protocol response
classification | meaning |
---|---|
1XX | Said the message. This type of status code indicates that the request has been accepted and needs to continue processing. This type of response is a temporary response, containing only the status line and some optional response header information, and ending with an empty line. |
2XX | Indicates success. This type of status code indicates that the request has been successfully received, understood, and accepted by the server. |
3XX | Redirection. This type of status code indicates that the client needs to take further action to complete the request. Typically these status codes are used for redirection, and subsequent request addresses (redirect targets) are specified in the Location field of this response |
4XX | Request error. Such status codes indicate that the client appears to have made an error that interferes with the server’s processing. Unless responding to a HEAD request, the server should return an entity that explains the current error condition and whether it is temporary or permanent. These status codes apply to any request method. The browser should show the user any entity content contained in such an error response. |
5XX | Indicates server error. This status code indicates that an error or exception occurs when the server processes the request. It may also indicate that the server realizes that the current hardware and software resources cannot complete the request processing. Unless this is a HEAD request, the server should contain an explanation entity that explains the current error state and whether the state is temporary or permanent. The browser should show the user any entities that are included in the current response. |
Common status code
Status code | Status code English name | describe |
---|---|---|
200 | OK | The request was successful, and the desired response header or data body is returned with this response |
202 | Accepted | Accepted, the request has been accepted, but processing is not complete |
206 | Partial Content | The server successfully processed part of the GET request (breakpoint continuation) |
| 301 | version Permanently | Moved Permanently, the requested resource has been a permanent move to the new UR, return to live UR new information package, the browser will automatically redirect to the new UR |. Any new request in the future should use new UR instead of | | 302 | Found | temporary mobile, similar to 301. But resources are moved only temporarily. The client should continue to use the original UR | | 400 | Bad Request | server receives and deal with. But unlike the type of client request, Server could Not understand | | 401 | Unauthorized | request to the user’s identity authentication (without permission) | | 403 | who | server to understand the client’s request but refused to carry out this request (enough permissions or error) | | 404 | Not Found | server is unable to find resources (web page) according to client’s request. | | 500 | nterna | Server erro | request no problem, Server error | | 502 | Bad Gateway | ACTS as a Gateway or proxy Server, from the remote Server received an invalid request |
HTTP state management. The Cookie and Session
Cookie
A Cookie is actually a small piece of text. It is used to record the user’s state. If the server needs to record the user’s state, it issues a Cookie(the first time) to the client browser, which saves the Cookie. When the browser requests again, the browser submits the Cookie to the server along with it. The server checks the Cookie to identify the user’s state
Session
Session is another mechanism for recording customer status.
Save client information to the server. The next time you visit, you just need to look up the status of the client from the Session
But it will increase the strain on the server. Consider setting Session expiration dates. This relieves server stress
contrast
-
location
Cookies exist with the browser. Session storage server
-
Different security
For the same reason. Some browser operations can modify or steal cookies
-
Different expiry dates
-
Different server pressures (explained)
Cookie && session
Deep into the HTTP
Character set and encoding
What is coding?
As you all know, computers are stored in binary. But what we need to see. It should be English, Chinese or something. How to make the binary of the computer into Chinese that we can understand or whatever. That’s where we need to use code
In a nutshell. Coding is the process of compiling the binaries in a computer into words we can understand
Different languages have different coding specifications (putting the same binary into different language text), such as Chinese GBK and so on
Let me draw it as a graph. Here is just a brief introduction, interested friends baidu themselves
Decode and garble
Decoding is the reverse process of coding
And the code. Is in the process of decoding, the use of a different way of decoding and encoding. Make the information display not as expected. It’s called garbled code
Long links and short links
HTTP protocol is based on request/response mode, so as soon as the server gives a response, the HTTP request ends.
HTTP long and short connections are essentially TCP long and short connections.
HTTP long and short links
We talked about that before. It’s in the developer tools. Find Network and click on a web page. Find the Response Headers
This represents a long connection between us and the server. A certain amount of time. We can go all the way through this connection, which will speed up access etc
In simple terms
Short link
Establish a connection –> Data Transfer –> Disconnect……….. Establish a connection –> Data transfer –> Disconnect
Long connection (frequent requests)
Establish a connection –> Data Transfer –> Maintain the connection ——> Data transfer –> Disconnect
agents
This is what we often call a Proxy. Needless to say. We all use it all the time
Is to act as a middleman.
For example, the front-end can use a Node server as a proxy. Clean the data. Jump out of the browser’s cross-domain mechanism and so on.
I’m not going to say much here
Gateway mediation
Here is a brief introduction. Interested friends baidu to learn more
A gateway can be used as a kind of translator that abstracts out a way to reach a resource. Gateways are the glue between resources and applications. In a nutshell. As a protocol converter
So you can see that. The proxy travels between protocols, while the gateway travels between different protocols
So there are two kinds of gateways
Server side Gateway (HTTP/)
: Communicates with the client over HTTP and communicates with the server over other protocols.Client Gateway (/HTTP)
: Communicates with clients over other protocols and with servers over HTTP
HTTP cache
Each request made by the client. The server has to return. If there are too many requests and too many files, there will be a lot of pressure on the server.
If you store some static resources, resources that don’t change very often. The client requests again. Just request files that you don’t have or change. This also relieves the strain on the server. It also speeds up web page loading
The cache control
-
Cache-control field in the request/response header. Called the control cache field. Common values are
No-store: all contents will not be cached. No-cache: the browser will request the server to check whether the cached resources are up to date before using the cache. Max-age =x: (unit: second) λ seconds after a cache request is received, no more requests will be sent. S-maxage =x :(in seconds) the proxy server does not send requests to the CDN cache in λ seconds after requesting the source cache. Public: client and proxy server (CDN can be cached. Private: Only clients can cache
-
Last-Modified
The response header, when the resource was last modified, is told by the server to the browser.
If-modified-since the request header, which is told by the browser to the server when the resource was LastModified, is compared to LastModified.
-
Etag Response header, resource identifier, told by the server to the browser. If-none-match request header, cache resource identifier, by the browser to the server (Etag).
Way to work
- Set up aFile expiration time
Expires
, time does not expire, go to the browser cache, expired on the request server again - In addition to setting the file expiration time, add aComparison of the latest file modification time–
Last-Modified
withif Modified-Since
If the file is expired. Compare the modification time. If you compare it. Go to cache - Based on the above. Add another oneUnique comparison mark for file contents–
Etag
withif-NoneMatch
. Expires is unstable. Add another onemax-age
(Priority is greater than Expires). So requestedmax-age
Inside, go cache. Out of time. contrastEtag
(Priority). Change the request, do not change the cache
The improved scheme
In order to solve this problem, the client cannot actively query the file changes on the server. We have a new approach
-
MD5/Hash cache, which requests static files with MD5 or Hash identifiers if the files change. Hash/MD5 also changes and the client requests a new file
-
CDN cache
CDN is a content distribution network built on the network. Relying on the edge servers deployed in various places and through the function modules of load balancing, content distribution and scheduling of the central platform, users can obtain the content they need nearby, reduce network congestion and improve user access response speed and hit ratio.
For example, there are many train ticket sales agencies in some cities. So we don’t have to go to the train station to buy tickets, we can go to the agent. It relieves the pressure on the railway station. Speed up the purchase of train tickets
Content negotiation mechanism
The client and server negotiate the resource content of the response and then provide the most suitable resource to the client. Content negotiation is based on the language, character set, encoding, and so on of the responding resource.
Three ways
-
Client driver
The client initiates a request, the server sends a list of options, and the client makes a selection before sending a second request.
-
Server driver (most widely used)
The server examines the client’s request Header set (Accpet) and decides which version of the page to serve.
-
Transparent negotiation
Some intermediary device (usually a caching proxy) negotiates on behalf of the client.
Request/response header set
The HTTP packet structure analysis is written above, so let me write it over here
Accept-language: Tells the server what Language to send accept-charset: tells the server what character set to send Accept-encoding: tells the server what Encoding to send
The bottom corresponds to the top
Content-Type
Content-Language
Content-Type
Content-Encoding
You can also approximate a match by q. The higher the weight, the higher the priority
Breakpoint continuation and multithreaded download
HTTP is implemented with two parameters in the Header, Range for the client to send a request and Content-range for the server to respond.
Range
Range: unit=(first byte pos)-[last byte pos] Range: unit=(first byte pos)-[last byte pos]
Content- Range
Used in response headers, after making a request with Range, the server returns the currently accepted Range and total file size in the Content-range header. General format
Content-Range: bytes(unit first byte pos)-[last bytepos]/[entity legth]
After the response is complete, the response header is returned with a different content
HTTP / 1.1 200 ok
(Do not use breakpoint continuation mode)HTTP / 1.1 206 PartialContent
(Use breakpoint continuation mode)
HTTPS
HTTPS (full name: Hyper Text Transfer Protocol over SecureSocket Layer is a secure HTTP channel. On the basis of HTTP, transmission encryption and identity authentication ensure the security of the transmission process [1] HTTPS adds SSL layer on the basis of HTTP. The security basis of HTTPS is SSL, so the details of encryption need SSL. HTTPS has a different default port from HTTP and an encryption/authentication layer (between HTTP and TCP). This system provides authentication and encrypted communication methods. It is widely used for security-sensitive communication on the World Wide Web, such as transaction payment and so on
Https can be regarded as HTTP+TLS. TLS is a transport layer encryption protocol, and its predecessor is SSL.
In terms of graphs
Differences between HTTP and HTTPS
HTTP
It’s plaintext transmission,HTTPS
throughTLS/SSLIt’s encryptedHTTP
The port number of theHTTPS
Is 443HTTPS
A certificate is required and costs varyHTTP
Is simple and stateless;HTTPS
The protocol is a network protocol that uses SSL and HTTP to encrypt transmission and authenticate identity. It is more secure than HTTP.
The advantages and disadvantages
advantages
- Data security: Users and servers can be authenticated using THE HTTPS protocol to ensure that data is sent to the correct clients and servers
- Data integrity: HTTPS is a network protocol constructed using SSL and HTTP to encrypt transmission and authenticate identity. It is more secure than HTTP and protects data from being stolen or altered during transmission, ensuring data integrity
- Increased attack costs. HTTPS is the most secure solution under the current architecture. It is not absolutely secure, but it significantly increases the cost of man-in-the-middle attacks
disadvantages
- In the same network environment, HTTPS extends the page load time by nearly 50% and increases the power consumption by 10% to 20%. In addition, HTTPS will affect the cache and increase data overhead and power consumption [2].
- The security scope of HTTPS protocol is limited, and it plays almost no role in hacker attack, denial of service attack and server hijacking [2].
- Limited and SSL system, the most critical is that SSL certificate credit chain system is not secure. Especially in cases where some countries can control CA root certificates, man-in-the-middle attacks are also feasible [2].
- Cost increases. After HTTPS is deployed, extra computing resources are consumed. For example, the ENCRYPTION algorithm of SSL and the number of SSL interactions consume computing resources and server costs. In the scenario of large-scale user access to applications, the server needs to perform frequent encryption and decryption. Almost every byte needs to be encrypted and decrypted, which increases the server cost.
webSocket
Websocket is another protocol based on HTTP
What is a webSocket? Why do we need it?
The simple answer is that the HTTP protocol has a flaw: communication can only be initiated by the client.
The browser needs to make continuous requests to the server. However, HTTP requests may contain long headers and only a small portion of valid data, which obviously wastes a lot of bandwidth and other resources. Maybe we can use the way of long link, but it will consume server resources. To solve this problem, websockets were invented.
Compared to the HTTP
Websocket is a persistent protocol. In contrast to HTTP, a non-persistent protocol.
The HTTP lifecycle is defined by a Request, which is a Response to a Request. In HTTP1.0, the HTTP Request ends. HTTP1.1 has been improved to have a keep-alive, which means that multiple requests can be sent and multiple responses received within an HTTP connection. But remember that Request = Response, which is always the case in HTTP, means that there can only be one Response per Request. Moreover, this response is also passive and cannot be initiated actively
Bring me the top picture again.
WebSocket
GET /chat HTTP / 1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 13
Origin: http://example.com
Copy the code
Compare that to an HTTP request.
Upgrade: websocket
Connection: Upgrade
Copy the code
These two things tell the server that I’m sending the WebSocket protocol
Randomly generated by the browser for verificationSec-WebSocket-Key: X3JJHMbDL1EzLkh9GBhXDw == Distinguishes service agreementsSec-WebSocket-Protocol: Chat, superchat protocol version. But it's settled nowSec-WebSocket-Version: 13
Copy the code
Return the following. The protocol switchover succeeds
HTTP / 1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
Sec-WebSocket-Protocol: chat
Copy the code
Sec-websocket-accept: indicates the encrypted sec-websocket-key. Sec-websocket-protocol: indicates the Protocol used
The role of the Websocket
Before we do that, let’s explain Ajax polling and long polling
Ajax polling
Easy to understand. I just wrote a timer. Ask the server every once in a while to see if any messages come back
function ajax(){
axios.get().then(res= >{
alert('The message of Ajax is'+' '+res); })}setTimeout (function(){
ajax();
},1000);
Copy the code
The picture says
Long poll
In fact, the principle of Long Poll is similar to that of Ajax polling, which adopts the polling method, but adopts the blocking model (keep calling and do not hang up if you do not receive the call). That is to say, after the client initiates a connection, if there is no message, it does not return the Response to the client. It does not return until there is a message, after which the client establishes the connection again and the cycle starts again.
Without further ado. Directly above
The way the webSocket
Directly above
The resources
Baidu Encyclopedia – HTTP
Baidu Encyclopedia – HTTPS
Mooc – Big talk HTTP
Computer Networking (6th Ed.) by Xie Xiren
By the end of this HTTP post, you’ll be fine with bickering with your interviewer
How does WebSocket work