Features of the HTTP protocol

HTTP is a part of object-oriented application layer protocol, HTTP protocol, a total of five characteristics: 1, supports the client / server model; 2, simple and fast; 3, flexible; 4, no connection; 5, stateless.

no connection

Meaning No connection is to limit the processing only one request per connection. After the server processes client requests and receives the customer's response, i.e., disconnected. In this way it can save transmission time.

The reason for this is early HTTP protocol generated on the Internet, so the server at the same time for the world to deal with hundreds of thousands, millions of web access client, but intermittent exchange of data between each client (ie browser) and server of large (ie transmission with sudden, transient), and web browsing associative, leading to divergent data association of two transmissions is very low, in fact, most of the channels will be idle, for no reason footprint. So HTTP designers interested in using this feature of the protocol is designed to build the connection request, complete connection release request to release the resource service other clients as soon as possible.

Over time, the page becomes more and more complex, which may be embedded in a lot of pictures, this time each time you visit the images have to establish a TCP connection becomes very inefficient. Later, Keep-Alive it has been proposed to solve the low efficiency of this problem.

Keep-Alive feature allows the client to server connection remain in effect when subsequent requests to the server appears, Keep-Alive feature prevents establish or re-establish the connection. Most Web servers on the market, including iPlanet, IIS and Apache, all support HTTP Keep-Alive. For static content sites, this feature is often useful. However, for heavier burden on web sites, where there is another problem: Although open connection to customer retention has certain advantages, but it also affects the performance, because during the processing pause, could have released resources are still occupied . When the Web servers and application servers running on the same machine, the Keep-Alive feature on the impact of resource use in particular.

Thus, HTTP connection between the client and the server will be held, is not disconnected (except Keep-Alive exceeds a predetermined time, an unexpected power outage, etc.), when the client sends another request, on the use of this connection has been established.

no status

No state is no protocol for transaction processing and memory, the server does not know what the client state. After that we are sending an HTTP request to the server, upon request, we will send the data over, however, send, has not recorded any message.

HTTP is a stateless protocol, which means that each request is independent, Keep-Alive did not change this result.

If the lack of state means that the subsequent processing required in front of the information, it must be retransmitted, which may result in the amount of data transmitted for each connection is increased. On the other hand, when it does not require previous information in response to a faster server.

HTTP protocol This feature has advantages and disadvantages, the advantage of the liberation of the server, each request "go beyond" the connection will not cause unnecessary occupation, the disadvantage is that each request would transfer large amounts of duplicate content information.

After the Web application client and server interact dynamically appear, HTTP stateless characteristics of a serious impediment to the realization of these applications, after all, is the need to interact with the past and simple shopping cart program also need to know what in the end user before selecting the commodity. Thus, two techniques for maintaining HTTP connection state is adopted, one cookies, while the other is Session.

Cookie can keep the conversation next time the user login information to the server, in other words, the next time you visit the same Web site, users will find not need to enter a user name and password are already logged in (of course, does not rule out manually delete Cookie). And there are some Cookie when the user exits the session is deleted, so you can effectively protect personal privacy.

The most typical application is to determine whether Cookies registered users already visit the website, the user may be prompted whether to retain user information when a site next to enter the simplified registration procedure, these are the Cookies function. Another important application is the "shopping cart" like handling. Users may choose different products with different pages of a website in over a period of time, this information will be written Cookies, in order to extract information at the time of final payment.

Cookie and opposite a solution Session, which is held to the state of the server.

When a client access server, the server set according to demand Session, session information stored on the server, while marking Session of SessionId passed to the client browser, the browser will SessionId stored in memory, we call non-expired Cookie time. After the browser is closed, the Cookie will be cleared away, it does not exist in the Cookie user's temporary files.

After each time the browser requests will add additional value of this parameter, the server will be based on this SessionId, we will be able to obtain information about the client's data.

If the client browser unexpectedly closes, server Session data is not saved immediately released, this time the data will continue to exist as long as we know that SessionId, you can continue to receive the information in this Session by request, because at this time there is a background of Session, of course, we can set up a Session timeout, once exceeds the allotted time no client request, the server will clear the Session information corresponding to the SessionId.

The main characteristics of the HTTP protocol can be summarized as follows:

1. Supports client / server model.

2. simple and fast: a customer service request to the server, instead of sending the request method and path. Request method commonly used GET, HEAD, POST. Each method provides a different type of client contacts the server. Due to the simple HTTP protocol, HTTP server makes the program a small scale, so the communication is very fast.

3. Flexible: HTTP allows the transmission of any type of data object. Type being transmitted by the Content-Type (Content-Type HTTP packet is used to indicate the type of content identifier) ​​to be labeled.

4. No connection: Meaning No limitation is attached only one request per connection. After the server processes client requests and receives the customer's response, i.e., disconnected. In this way it can save transmission time.

5. stateless: HTTP protocol is stateless protocol. No state is no protocol for transaction processing and memory. If the lack of state means that the subsequent processing required in front of the information, it must be retransmitted, which may result in the amount of data transmitted for each connection is increased. On the other hand, when it does not require previous information in response to a faster server.

Guess you like

Origin www.cnblogs.com/zyyhxbs/p/11510940.html