In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
One: introduction to HTTP
HTTP is the abbreviation of Hyper Text Transfer Protocol (Hypertext transfer Protocol).
Its development is the World wide Web Association (World Wide Web Consortium) and the Internet working Group.
As a result of the IETF (Internet Engineering Task Force) collaboration, a series of RFC,RFC 1945 defined HTTP/1.0 versions were eventually released.
One of the most famous is RFC 2616. RFC 2616 defines a version that is commonly used today-- HTTP 1.1.
HTTP protocol (HyperText Transfer Protocol, Hypertext transfer Protocol) is a transport protocol used to transfer hypertext from a WWW server to a local browser.
It can make browsers more efficient and reduce network transmission. It not only ensures that the computer transmits the hypertext document correctly and quickly, but also determines which part of the document to transfer.
And which part of the content is displayed first (such as text before graphics) and so on.
HTTP is an application layer protocol, which consists of requests and responses, and is a standard client-server model. HTTP is a stateless protocol.
Http://cimc-express.com/ is the elder URL, called the uniform resource locator. HTTP is called a protocol, and cimc-express.com is a domain name that represents the Internet
A position in the. The browser will resolve the cimc-express.com to the IP address. HTTP is based on the TCP protocol, so you need to establish a TCP connection first.
Most of the HTTP protocols currently in use are 1.1. In the 1. 1 protocol, Keep-Alive is enabled by default, so that TCP connections established can be reused in multiple requests.
Two: HTTP sends messages
The HTTP message is roughly divided into three parts. The first part is the request line, the second part is the header of the request, and the third part is the body entity of the request.
1. Request line
URL is http://cimc-express.com, and the method types in HTTP1.1,HTTP are:
GET: go to the server to get resources. For visiting a web page, it is a page. For an API based on HTTP protocol, it may return a
JSON string
POST: submit resources to the server
PUT: submit resources to the server. POST is often used to create a resource, and PUT is often used to modify a resource.
DELETE: deleting resources
two。 First part
The first is in the form of key:value, which holds some very important fields. Accept-Charset represents the character set acceptable to the client, and Content-Type refers to the text's
Format, Cache-Control is used to control the cache.
3. Body entity
Three: HTTP data transmission
The 1.HTTP protocol is based on the TCP protocol. It sends requests in a connection-oriented way and sends them to each other through stream binary streams. When you get to the TCP layer, you will put the
The binary stream becomes a message segment and is sent to the server.
two。 When sending each message segment, the other party needs a response ACK to ensure that the message arrives reliably. If there is no response, then the TCP layer will
Retransmit until it can be reached. The same package may have been uploaded many times, but the HTTP layer does not know this.
When sending each message, the 3.TCP layer needs to add its own address (source address) and the address it wants to go (destination address), and put these two messages into the IP header.
Inside, give it to the IP layer for transmission.
The 4.IP layer needs to check whether the destination address and itself are on the same local area network. If so, send the ARP protocol to request the MAC address corresponding to this destination address, and then set the
Put the source MAC address and destination MAC address in the MAC header and send it out; if not, you need to send it to the gateway and send the ARP protocol to obtain the gateway's
MAC address, and then put the source MAC address and gateway MAC into the MAC header and send it out.
5. The gateway receives the packet and finds the MAC match, takes out the destination IP address, finds the next hop router according to the routing protocol, obtains the MAC address of the next router, and sends the packet.
Give me a surprise route.
6. When the target machine finds that the MAC address matches, it puts the packet away; it finds that the IP address matches, and according to the IP top priority agreement item, it knows that its upper layer is the TCP protocol, so it solves the problem.
Analyze the TCP header, which contains the serial number. You need to see if this serial number is what I want. If so, put it in the cache and return an ACK. If not, discard it.
There is also a port number in the 7.TCP header, which is being listened to by HTTP's server. Therefore, the target machine naturally knows that it is the HTTP server that the process wants the package.
The package is then sent to the HTTP server. The process of the HTTP server sees that the original request is to access a web page, so it sends the web page to the client.
Four: HTTP return message
1. Status code
200: transaction succeeded, 400: error request 404: no file, query or URl 500 found: internal server error 502: gateway error
two。 Return to the first key:value. Retry-After indicates how long the client should try again, and Content-Type indicates whether HTML is returned or
JSON .
3. The returned HTTP message is constructed, and the next step is to send it out. Whether to send it to Socket or to TCP layer, so that the TCP layer will return the
HTML is also divided into small segments, and each segment is guaranteed to arrive reliably.
Five: HTTP2.0
1.HTTP1.1 communicates in plain text at the application layer, each time with a complete HTTP header, and regardless of pipeline mode, each process
I always go back and forth. There are problems in real-time and concurrency.
2.HTTP2.0 will compress the HTTP header to set up an index table at both ends of the large number of key:value originally carried every time, and only send the same header.
The index in the index table.
3.HTTP2.0 protocol splits a TCP connection into multiple streams, each with its own ID, and the stream can be sent from the client to the server or a service
The end sends it to the client, which is actually just a virtual channel, and the stream has priority.
4.HTTP2.0 also divides all transmission information into smaller messages and frames and encodes them in a secondary format. A common frame is the Header frame, which is used for transmission
Header content, and will open a new stream. Then there is the Data frame, which is used to transmit the body entity, and multiple Data belong to the same stream.
5. Through these two mechanisms, HTTP2.0 clients can divide multiple requests into different streams, and then split the request content into frames for binary transmission. These frames can be
It is sent out of order, and then reassembled according to the flow identifier at the beginning of each frame, and the data of which stream can be processed first can be decided according to the priority.
For example: a page sends three separate requests, one to get css, one to get js, and one to get image jpg. If HTTP 1.1 is used, it is serial; but if
With HTTP 2.0, both the client and the server can send multiple requests or responses at the same time in a single connection, without having to correspond one-to-one sequentially.
HTTP2.0 successfully solves the problem of blocking at the head of HTTP1.1, at the same time, it does not need to use multiple TCP connections to implement parallel requests through the pipeline mechanism of HTTP 1.x.
And response; reduces the impact of the number of TCP connections on server performance, and transmits multiple data such as css,js,jpg of the page through a data connection, which can speed up the page.
The transmission speed of the facet component.
Six: QUIC
Although HTTP 2. 0 has greatly increased concurrency, it is still problematic. Because HTTP 2.0 is also based on the TCP protocol, the TCP protocol processes packets in a strict order.
. Google's QUIC protocol is based on UDP implementation and includes a custom connection mechanism.
Custom retransmission mechanism, non-blocking multiplexing and custom flow control.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.