Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Http Protocol of Web (1)

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

How do we use the web website?

First, we will enter the address of the web website in the address bar of the browser. Then you can see the relevant content in the browser. In fact, this process is that the web browser requests the web server, and then receives the content of the web server and presents it to us. This process is regulated by a hypertext transfer protocol (http protocol) to complete the process. In other words, web is based on http protocol, which shows the importance of HTTP protocol.

II. The history of HTTP agreement

1.HTTP/0.9

Request: GET / index.html

Response: the server can only respond to strings in HTML format, not in other formats.

Hello World

2.HTTP/1.0

First of all, content in any format can be sent. This makes it possible for the Internet to transmit not only text, but also images, videos and binary files. This has laid the foundation for the great development of the Internet.

Secondly, in addition to the GET command, the POST command and HEAD command are introduced to enrich the interaction between the browser and the server.

Third, the format of HTTP requests and responses has also changed. In addition to the data part, each communication must include header information (HTTP header) to describe some metadata.

Cons: the main disadvantage of the HTTP/1.0 version is that only one request can be sent per TCP connection. When the data is sent, the connection is closed, and if additional resources are requested, a new connection must be created.

3.HTTP/1.1

Persistent connections: that is, TCP connections are not closed by default and can be reused by multiple requests without declaring Connection: keep-alive. For the same domain name, most browsers allow six persistent connections to be established at the same time

Pipeline mechanism: the pipeline mechanism allows the browser to send A request and B request at the same time, but the server still responds to A request first, and then responds to B request after completion.

Disadvantages:

The server will not make the next response until it has processed one response. If the previous response is particularly slow, there will be a lot of requests waiting in line. This is called head-of-line blocking (Head-of-line blocking). To avoid this problem, there are only two ways: one is to reduce the number of requests, and the other is to open more persistent connections at the same time. This leads to a lot of page optimization techniques, such as merging scripts and stylesheets, embedding images into CSS code, domain name fragmentation (domain sharding), and so on.

4.HTTP/2

Binary protocol

The header information of the HTTP/1.1 version must be text (ASCII encoded), and the data body can be text or binary. HTTP/2 is a thorough binary protocol, header information and data body are binary, and collectively referred to as "frame": header information frame and data frame.

Multiplex

HTTP/2 reuses TCP connections, in which both the client and the browser can send multiple requests or responses at the same time, and do not have to correspond one by one in order, thus avoiding "head-of-line congestion".

At present, we are using HTTP/1.1.

III. Various agreements related to http

1.tcp/ip protocol

The networks commonly used, including the Internet, operate on the basis of the TCP/IP protocol family. And HTTP belongs to a subset of it. According to the hierarchy, the TCP/IP protocol family is divided into the following four layers: application layer, transport layer, network layer and data link layer. The communication process is as follows:

2.IP protocol

The function of the IP protocol is to send various packets to each other. In order to ensure that it is indeed transmitted to the other party, various conditions need to be met. Two of the important conditions are the IP address and the MAC address. The IP address indicates the address to which the node is assigned, and the MAC address refers to the fixed address to which the network card belongs. IP addresses can be paired with MAC addresses. IP addresses are translatable, but MAC addresses are basically unchanged. The flow chart is as follows:

3.tcp protocol

The so-called byte streaming service (Byte Stream Service) means that in order to facilitate transmission, large chunks of data are divided into packets in terms of message segments (segment) for management. Reliable transmission service refers to the ability to transmit data to each other accurately and reliably. In a word, the TCP protocol splits the data in order to make it easier to transmit big data, and the TCP protocol can confirm whether the data is finally sent to the other party.

The sender first sends a packet with the SYN flag to the other party. After receiving it, the receiver sends back a data packet with the SYN/ACK flag to convey the confirmation message. Finally, the sender sends back a packet with the ACK flag, which represents the end of the handshake.

4.dns service

DNS (Domain Name System) service is a protocol located at the application layer like the HTTP protocol. It provides resolution service from domain name to IP address.

5. The relationship between each protocol and http protocol

IV. The relationship and difference of URI,URL,URN

The uniform resource marker URI means that a resource can be uniquely identified under a certain rule. Take a person as an example, assuming that the names of all people in the world can not be repeated, then the name is an instance of URI, through the name string can identify a unique person. In reality, of course, the name will be repeated, so the × × number is the URI, through the × × number allows us to identify only one person.

What is the uniform resource locator URL? Also take a person as an example and make an analogy with HTTP's URL, you can have an animal address agreement: / / Earth / China / Guangdong Province / Foshan City / Chancheng District / a building / a unit / a seat / Zhang San. You can see that this string also identifies a unique person and plays the role of URI, so URL is a subset of URI. URL is the only way to identify a person by describing his location.

In the above, we can use the × × number to identify only one person. For this Zhang San in Foshan, we can also use:

X × × number: 123456789 to identify him. So no matter using the way of positioning or numbering, we can only identify a person, which is an implementation of URl, and URL is the URI realized by positioning.

Back on the Web, suppose that all Html documents have a unique number, which is recorded as a string of numbers, that is, the × × × number of the Html document, which uniquely identifies a Html document, then the number is a URI. On the other hand, URL implements URI by describing the files on which host and which path to uniquely determine a resource, that is, the way of location.

For the current URL, I prefer to call it URL, after all, it provides the location information of the resource, if one day the URL is identified by number to become http://741236985.html, it feels more appropriate to call it URI, but in this case we have to find a way to find this resource!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report