The HTTP protocol acts on both the client and server side, and the client and server are a relative role, but the communication must be achieved through the exchange of requests and responses, and the HTTP protocol stipulates that the client must make a request to establish communication, and the servers will not send a response when the request is not received.
The request message is composed of the request method, the request URI, the protocol version, the request header field, and the content entity.
The following is the format in which the client sends request messages to a server-side:
The server that receives the request returns the processing result of the requested content to the server in response.
The response message is basically composed of the Protocol version, the status code, the reason phrase of the status code and the optional response header field as well as the entity body.
The following is the format of the response message composition:
Because the HTTP protocol is a protocol that does not hold state, it means that it does not save the state of communication between requests and responses, which speeds up the processing of a large number of things and ensures the scalability of the Protocol.
Because the HTTP protocol uses URIs to locate resources on the Internet, any resource on the internet can be searched by URI. There are two ways to specify the request URI:
URI for the complete request URI |
GET http://hackr.jp/index.htm http/1.1 |
in the header field HOST Specify the network domain name or IP Address |
Get/index.htm http/1.1 Host:hackr.jp |
The HTTP method that tells the server intent is the following table:
Method |
Description |
supported HTTP Protocol version |
GET |
Get Resources |
1.0/1.1 |
POST |
Transport entity Body |
1.0/1.1 |
PUT |
Transferring files |
1.0/1.1 |
HEAD |
Get message header |
1.0/1.1 |
DELETE |
deleting files |
1.0/1.1 |
OPTIONS |
Ask for supported methods |
1.1 |
TRACE |
Trace Path |
1.1 |
CONNECT |
Linkages between building and resources |
1.1 |
HTTP1.1 is more persistent and pipelined than HTTP1.0, and continuous connections can reduce the overhead of each session disconnection and connection, while pipelining can enable the ability to send multiple requests concurrently.
Because the HTTP protocol is a stateless protocol, a cookie technology is introduced in order to achieve the ability to keep the login state.
Cookie technology controls the state of the client by writing cookie information in the request and response messages.
The cookie notifies the client to save the cookie based on a header field message called "Set-cookie" within the response message sent by the server. When the next client sends the request again, the client automatically adds the cookie value to the service side after the request message is received, and the server receives the cookie sent by the client, checks to which client the cookie came from, and then, for the data before it, Finally get the status information of the previous client.
A simple HTTP protocol