basic introduction
HTTP (HyperText Transfer Protocol, Hypertext Transfer Protocol) is one of the most widely used network protocol.
HTTP from the initial birth until now, there are the following versions
- 0.9 (original version has been basically not in use)
- 1.0 (initial normal, but the agreement is still being widely used standard)
- 1.1 (the current mainstream HTTP protocol version)
- 2.0 (still under development)
HTTP at the level of a computer network in accordance with TCP / IP application layer is a layered model
TCP/IP模型是对计算机网络整体体系结构的一种分层划分,分层的主要目的是为了最大降低计算机网络体系模块与模块之间的耦合性
Feature
-
HTTP connections are stateless, HTTP connection before the state will not save
这样设计的主要目的是为了更加灵活HTTP的使用 但是现实需要保存HTTP的连接状态,比如记录用户的登录状态。于是就引入了Cookies技术,来管理连接状态
-
Persistent connections
随着HTTP的广泛使用,HTTP的请求次数变得越来越多 为了减少HTTP连接所带来的代价,于是在HTTP1.1版本就引入了持续连接 持续连接就是:只要连接双方都没有提出断开连接的请求,则就会一直保持tcp的连接状态
-
Pipelining
客户端在发送HTTP请求时,可以不必等待服务端对HTTP的响应,可以直接进行下一个HTTP请求
practical use
-
HTTP is now widely used in the exchange of client and server data.
-
The client sends an HTTP request sends the data to the server, and the server responds accordingly HTTP request, returned to the client
-
HTTP protocol can clearly distinguish which end is the client, which is a server-side
-
The request must be sent by the client, and the server replies response
-
The client sends http request is called the request packet
-
According to the response server http request packet is made is called the response packet
1. The data structure of the request message
请求方法 URI HTTP版本
可选的请求首部字段
内容实体
Common request methods in the following table
Request method name | Instructions |
---|---|
GET | Access to resources (most common) |
POST | Transport entity body (most commonly used) |
PUT | Transfer files |
HEAD | Get the message headers |
DELETE | Delete Files |
OPTIONS | Inquiry method Supported |
TRACE | Track the path. This method is to let Web server requests a method of communicating back to the client before the (rarely used) |
CONNECT | Requirements for Tunneling Protocol Connection Broker (rarely used) |
2. The structure of the response data packet
HTTP版本 状态码 状态码的原因短语
可选的响应首部字段
主体
The response status code classification shown in the following table
category | The reason phrase | |
---|---|---|
1XX | informational will (informational status codes) | The received request is received |
2XX | Success (success status code) | Normal requests processed |
3XX | Redirection (Redirect Status Code) | Additional operation required to complete the request |
4XX | Client Error (Client Error Status Code) | Service can not process the request |
5XX | Server Error (server error status code) | Server request error |