Really "engage" in understanding HTTP protocol 01-Background story

Source: Internet
Author: User
Tags ack

Last year read "Illustrated http", "Graphic TCP/IP" and "Graphic network hardware" but after reading there is no deep impression, but with a vague context, just recently contacted some of the relevant content of HTTP. So, we are going to write it in a series, on the one hand, you can make your understanding of HTTP more deeply. You can also do not understand the HTTP students in the study of the road first to remove the thorn, so that the road to learn more quickly and smoothly.

HTTP is a bridge between the front and back end, both the frontend and the backend, which is a very important basic knowledge. Most front-end development only focus on the layout of the page is not good, the CSS is not concise, JS readability reusability is not OK, the framework is not familiar with the familiar. But I think the basics like HTTP are very important. It is also an unavoidable problem in the programmer's career.

First, http meaning

The name of HTTP is called Hypertext Transfer Protocol ( H yper t ext  T ransfer  P rotocol), what is the Hypertext Transfer Protocol? We first understand the literal meaning of the transmission of the "Hypertext" protocol. For example, a and B two people, each person has a document called "hypertext", a according to the "protocol" to the "hypertext" File "(transmission)" B. This is the description of a comparison image of the Hypertext Transfer Protocol. Well, a by protocol to B is hypertext, protocol We are easy to understand, is a rule ... We must abide by this rule when we pass "hypertext" between A and B. It's like if you're driving a car, you can't drink alcohol, you have a heavy lift, and you hold your weight. So we must pay attention to open wine do not drink cars, drink cars do not open wine, wisdom ah. So we understand the protocol, what is hypertext ? Hypertext is super Text! It makes sense to say that .... Ah yo ... Stop it.. Wrong... Live foot ... Tap to kick ... Ah yo ... That's true. The text we know, can be interpreted as a document with graphic content. So what is super text (hypertext)? Hey... This is more interesting. Hypertext simply means that there is a hyperlink (Hyperlink) text in the text content, you can click on the hyperlink to jump to other content. This is the hypertext. There are many hypertext formats, and the most common is Hypertext Markup Language. Alas? Hypertext Markup Language? Sounds a little familiar to me? Hypertext Markup Language ( H yper T ext  M arkup  L Anguage). Lying in the slot, is that HTML? That's right. We walked a small circle and got around here. in a word, HTTP is a rule (protocol) used to pass (transmit) HTML (hypertext) between Web pages (small A and small b).

Ii. http from birth to present 

  We understand the meaning of the name of HTTP, like Zhangquan eggs, Wang Yiga names are also parents in the name of a profound implication in the inside. So it is necessary for us to understand the meaning of other people's names to help us understand them. So let's look at the history of HTTP from birth to growth.

In 1991 our http0.9 version was finally born (released), of course, before the release must also be "pregnant October", but we do not struggle to see how people are conceived, we have to struggle with what happened after the birth. Just born HTTP is still relatively young, okay, nonsense, who was born not young ... So its ability is not very strong. There is only one get skill, and you can only pass HTML-formatted strings , like today's JSON, XML, TXT, etc. Don't even think about it. After all, I'm still young ... Demand so much ... Really And in the 0.9 release, each HTTP request is a short link (what is described later is what is a short link).

Time flies, we came to 1996 years, at this time in 5 years, HTTP side work, side growth, finally, http1.0 version produced, our children have grown up, with more social experience and insight, with it, its ability has also improved a lot. At this point the HTTP has more skills, post and head. Has more features, including a bunch of things like the status code, cache, redirect (redirect), permissions (authorization), and so on that we're now familiar with. At this point the HTTP can be said to grow up for a can support a world of the head of the household.

Time continues to Wanfengchuidiao, at this time about half a year or so, the growth of HTTP is very rapid. At the beginning of 1997, http1.1 released a lot more HTTP skills, such as Options,put, DELETE, TRACE, connect and more. You know, http1.1 is the most commonly used HTTP version of our current.

Say a little bit http2 and https , in fact, we can find that the common browser domain address before the HTTP has become https, simply speaking, HTTPS is the security version of HTTP, In fact, HTTPS is encrypted data after the HTTP, so that the network transmission of data more secure, and the process of encryption is actually in the seven layer network model of the presentation layer and session layer to complete, And HTTP2 is in order to adapt to the modern browser and network development speed of a side of the performance of a better HTTP version.

Third, the network model

 Our goal is not to understand the entire internetwork model, but to learn one of the most necessary "background stories" before HTTP, so I'll give you a brief introduction to the internetwork model. Let's look at a picture first:

The left side of the figure is a five-layer network model, with a seven-layer network model in the middle, and the right side of each layer. In fact, the seven-tier network model is simply a thin separation between the presentation layer and the session layer in the application layer. If you want to learn more about the entire Internet model of the process and specific content, you can go to see Nanyi Teacher's Internet Protocol Introduction (a). You can also find your own information. This is not the focus of this series. You know, it's a huge knowledge system.

Every time we send a network request on the client is from top to bottom, to the server side and then from the bottom of a process. Of course, the response from the server back to the client is also on the server side from top to bottom, to the client and then to the bottom of the acquisition. That is, where the transmission is from the application layer to the physical layer, where it is received from the physical layer to the application layer.

四、三次 handshake

  In the process of sending HTTP requests and returning responses from the client and server, we need to create a channel that ensures that HTTP can be passed, which is the TCP connection established by the transport layer. After the connection has been established, we can complete the HTTP request and response. So how can I be sure that TCP connection has been created? Then a three-time handshake is required to determine that the connection has been established. Let's take a look at the picture and see how the three-time handshake works:

First the client sends a packet, the content of the package is a flag bit SYN and a random number seq is then sent to the server. At this time the server knows, oh this client wants to request a connection, then it returns a new packet, the same includes the SYN, and returns an ACK flag bit, and returns a value of +1 as an ACK on the received SEQ basis, and regenerates a new random number seq to the client. It means that I did receive the request. The client now receives the second return packet, and then tells the server that I received your message, and then passes the computed ACK and the newly generated SEQ to the server. At this point, three handshakes are complete and HTTP requests can be made.

Five, Uri-url, URN

Before we start the real content of HTTP, we need to know what URIs are, URLs, and urns. Because almost all of our HTTP requests are done via URLs. So we need to understand the URL-related knowledge.

The URI Uniform Resource Identifier (Uniform Resource Identifier), which is a string that identifies the name of an Internet resource.

The URL Uniform Resource Locator (Uniform Resource Locator), like the house numbers on the network, is the address of the standard resource on the Internet.

Urn Uniform Resource name (Uniform Resource name), which expects to provide a durable, location-independent identity for a resource, and allows you to easily map multiple namespaces to a single urn namespace.

In fact, the URL and urn is a subset of the URI, we look at a picture, the image source Wikipedia related articles:

Urn We are not common, just do a little understanding.

Six, message Format

  Let's take a look at this picture, which is an HTTP request I've been looking for on the Internet:

Everyone can open their own browser F12, in Netwrok casually looking for a request to see, then this is all the request header information. Includes common information (general) and a request header (requests header) and a response header (response header). But maybe what you see is not the same as mine. This is because the browser has formatted for us so that we can get the information we want more quickly. You can click on the button to see the source information, not the information after the parsed.

The red-framed part of the first picture is our starting line, and in view parsed, our browser omits the starting line, leaving only the header of the message, which is the other part of the red box. In addition to the starting line and header, there is a body, which is the content of the response returned by our server, we can view the formatted body content in preview.

The above content is very basic, not in-depth exploration, but for us to learn the next HTTP is enough to cut the necessary premise. If you want to learn more about each of these things, you can find the information yourself. There is quite a lot of content on the Web. Well, here's the end of the article, and the real HTTP official content will start here. Also hope that everyone on time to move the small bench, not late Oh.

Finally, because my level is limited, the ability and the great God is still very far apart, if there are errors or unclear, but also hope that everyone is not hesitate to correct. Thank you so much!

Really "engage" in understanding HTTP protocol 01-Background story

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.