Several versions of the HTTP protocol understanding

HTTP (HyperText transfer protocol) Hypertext Transfer Protocol

Http是一个应用层协议,基于TCP协议(传输层)之上,规定WWW服务器
浏览器之间信息传递规范。使用的默认端口号为80端口。

Http version of evolution

http 0.9:

最初的版本,只有一个命令GET,服务器只能回应HTML格式字符串。

http 1.0:

Introduces a new command POST and HEAD (http header data) commands
each TCP connection only send a request to send data is completed, the connection is closed, even if the request for additional resources, it is necessary to re-create a new connection
header is ASCII code, after the data may be in any format. The client tells the server to respond, what format the data is that the role of Content-Type field. These data types are collectively referred to as MIME Multipurpose Internet Mail Extensions i.e., each value comprising two types and a type of the predefined type, can also be custom type, Content-Type of common values: text / xml image / jpeg audio / mp3

http 1.1:

New method: PUT, PATCH, OPTIONS, DELETE

Introducing a persistent connection (persistent connection), i.e. does not close the TCP connection by default, multiple requests can be multiplexed without declaration Connection: keep-alive. For the same domain name, most browsers allow persistent connections while establishing six pipeline mechanism was introduced, that same TCP connection, the client can send multiple requests at the same time, to further improve the efficiency of the HTTP protocol

The same TCP connection, all of the data communication is carried out in sequence. Order processing server can only respond, in front of the slow response, there will be many requests are queued, resulting in "team head clogging" (Head-of-line blocking)

To avoid the above problems, two methods: one is to reduce the number of requests, while the second is more open persistent connection

In fact http1.1 still some unresolved issues

1. The transmission data is the plaintext
2.header long header data
3. Each transmission or to reconnect
4.server not actively push

This will promote the emergence of http2.0

Http2.0

HTTP2.0 is SPDY (https Google Inc. developed a protocol) upgraded version
1 header and body are binary data, called the header information and data frames
2. multiplex connection with TCP, a connection, the the client and the browser can simultaneously send multiple requests or respond to, and do not correspond in order to avoid the "team head clogging," this two-way real-time communication is called multiplexing (Multiplexing)
3. introducing header compression mechanism (header compression), header compression using gzip or compress before sending; the client and the server at the same time maintaining a table header, all fields will be stored in this table, to generate an index number, do not send the same field, just send the index number improve the speed
4.HTTP / 2 unsolicited allows the server, the client sends to the resource, i.e. a push server (server push)

Interview questions: http1.1 and the difference between http1.0

1. The long connection
HTTP 1.1 support long connections (PersistentConnection) and request pipeline (Pipelining) process, in a TCP connection may transmit a plurality of HTTP requests and responses, and close the connection establishment reducing consumption and delay in HTTP1.1 enabled by default connection: keep-alive, to make up for the shortcomings HTTP1.0 each request must create connections
2. cache deal
primarily header in the If-Modified-Since in the HTTP1.0, Expires do as a cache judgment standard, HTTP1.1 the introduction of more cache control policies such as Entity tag, if-Unmodified-Since , if-Match, if-None-Match , and more choice of head control cache caching strategy
3. Bandwidth optimization use and network connectivity
HTTP1.0, there are some wasted bandwidth phenomena, such as: the client only needs a portion of an object, and the server puts the whole object gets here and does not support the HTTP functionality, HTTP1. a range request header header field is introduced, which allows only a certain portion of the requested resource, i.e., the return code is 206 (Partial Content), to facilitate the selection of the developer in order to sufficiently free Bandwidth and connection
4. The error notification management
new HTTP1.1 24 states in response codes, such as
409 (Conflict) the resource request indicates resources and the current state of conflict;.
410 (Gone) represents a resource on the server permanently delete
5.Host header processing
In HTTP1.0 held that bind each server a unique IP address, therefore, request URL in the message did not get through the host name (hostname). But with the development of virtual mainframe technology, there can be multiple virtual hosts (Multi-homed Web Servers) on a single physical server, and they share a single IP address. HTTP1.1 request and response messages should support Host header field, and the request message if the Host is not an error report header field (400 Bad Request)

Guess you like

Origin www.cnblogs.com/luck-pig/p/12006908.html