3.4 字符集 3.5 Content Codings 3.6 Transfer Codings
4 HTTP消息
4.1 消息类型
- Request : client to server
- Response : server to client
- 消息数据
generic-message = start-line //start-line肯定有
*(message-header CRLF) //0到多个 header
CRLF // 空行
[ message-body ] //这是消息体(message-body),注意和entity-body 区分
start-line = Request-Line | Status-Line // 请求行 | 状态行
4.2 消息头
- 普通的头
- 请求头
- 响应头
- entity头(fields)
4.3 消息体
message-body = entity-body
| <entity-body encoded as per Transfer-Encoding>
4.4 消息长度
4.5 通用头
general-header = Cache-Control ; Section 14.9
| Connection ; Section 14.10
| Date ; Section 14.18
| Pragma ; Section 14.32
| Trailer ; Section 14.40
| Transfer-Encoding ; Section 14.41
| Upgrade ; Section 14.42
| Via ; Section 14.45
| Warning ; Section 14.46
5 Request 请求
Request = Request-Line ; Section 5.1
*(( general-header ; Section 4.5
| request-header ; Section 5.3
| entity-header ) CRLF) ; Section 7.1
CRLF
[ message-body ] ; Section 4.3
5.1 Request-Line
5.1.1 Method
5.3 请求头
request-header = Accept ; Section 14.1
| Accept-Charset ; Section 14.2
| Accept-Encoding ; Section 14.3
| Accept-Language ; Section 14.4
| Authorization ; Section 14.8
| Expect ; Section 14.20
| From ; Section 14.22
| Host ; Section 14.23
| If-Match ; Section 14.24
| If-Modified-Since ; Section 14.25
| If-None-Match ; Section 14.26
| If-Range ; Section 14.27
| If-Unmodified-Since ; Section 14.28
| Max-Forwards ; Section 14.31
| Proxy-Authorization ; Section 14.34
| Range ; Section 14.35
| Referer ; Section 14.36
| TE ; Section 14.39
| User-Agent ; Section 14.43
6 Response 响应
Response = Status-Line ; Section 6.1
*(( general-header ; Section 4.5
| response-header ; Section 6.2
| entity-header ) CRLF) ; Section 7.1
CRLF
[ message-body ] ; Section 7.2
6.1
- 1xx: Informational - Request received, continuing process
- 2xx: Success - The action was successfully received,
understood, and accepted
- 3xx: Redirection - Further action must be taken in order to
complete the request
- 4xx: Client Error - The request contains bad syntax or cannot
be fulfilled
- 5xx: Server Error - The server failed to fulfill an apparently
valid request
7 Entity
7.1 Entity Header Fields
entity-header = Allow ; Section 14.7
| Content-Encoding ; Section 14.11
| Content-Language ; Section 14.12
| Content-Length ; Section 14.13
| Content-Location ; Section 14.14
| Content-MD5 ; Section 14.15
| Content-Range ; Section 14.16
| Content-Type ; Section 14.17
| Expires ; Section 14.21
| Last-Modified ; Section 14.29
| extension-header
extension-header = message-header
7.2 Entity Body
8 Connections
8.1 长链接(持久的链接)
优点
- 管理(打开、关闭)更少的链接,更少的资源(CPU/memory)占用
- 网络争抢更少
- 减少建链,降低延时
8.2 长连接是默认
9 Method Definitions 方法定义
9.2 OPTIONS
9.3 GET
9.4 HEAD
9.5 POST
9.6 PUT
9.7 DELETE
9.8 TRACE
9.9 CONNECT
10 状态码定义(Status Code Definitions)
10.1 1xx
100
101
10.2 2xx Successful
###