HTTP protocol communication Both sides must be client and server side, and must be issued by the client request, the server accepts the request
The composition of the message sent by the client:
The message composition of the server-side response after receiving the request:
There are several ways that clients send requests to the server side:
Get: Gets the resource that is used to request access to a resource that has been identified by the URI. The specified resource returns the response content after the server-side resolution. If the requested resource is text, it is returned as it is, and if it is a program like the CGI (Universal Gateway Interface), it returns the output that was executed.
Post: Transport entity body, get can also be transferred, but generally not get transfer
Put: Transfer files, just like the FTP protocol file upload, the request in the body of the requestor to include the contents of the file, and then save to the request URI specified location, but because of an unlimited identity, security is too poor, so the general Web site does not use this method
Head: Gets the header of the message, just like the Get method, but does not return the main part of the text
Delete: deleting files, same as put
Options: Ask the Supported method, the server will return: Get,pust,options and other content
Connect: Requirements in the communication with the proxy server to establish a tunnel, the implementation of the tunnel protocol for TCP communication, mainly using SSL (Secure Sockets Layer) and TLS (Transport Layer Security) protocol to encrypt the communication after the network tunnel transmission, the server side returned to the tunnel after the OK
Trace: Trace path that allows the Web server to loop back the previous request communication to the client's method
Remedies and fixes for some of the shortcomings of http:
1.HTTP protocol in the initial version of each HTTP communication is to disconnect a TCP connection, if the requested page contains a large number of pictures, each request to connect, and then disconnect, will cause traffic overhead, in order to solve this problem, http/1.1 used a persistent connection method.
Persistent connection: Keeps the TCP connection state as long as no one end explicitly presents a disconnect
A persistent connection makes it possible to send multiple requests without waiting for a response one after another, without waiting for a response, to send the next request directly, which is the pipelined
Persistent connections make requests faster, and pipelining makes requests quicker
The 2.HTTP protocol is a stateless protocol, that is, it does not save the State of requests and responses that have occurred before, and cannot perform this request processing according to the previous state.
Benefits: Saves server-side memory resources and CPU consumption
Cons: When a user logs on to a site to browse, each jump to a new page will be re-login
Workaround: Cookie Technology: Write cookie information in request and response messages to control the state of the client. The cookie notifies the client to save the cookie according to a header field message in the response message sent from the server, and the client automatically adds the cookie value to the request message when the next client sends a request to the server, After the server-side discovers the cookie sent by the client, it checks the connection request from which client, then compares the records on the server, and finally obtains the previous state information.
http--Study notes (2)