Recording the Way

Learning Http

2018/01/05

Request

1
2
3
4
5
6
Request = Request-Line
*(( general-header
| request-header
| entity-header ) CRLF)
CRLF
[ message-body ]

Request-Line

1
Request-Line = Method SP Request-URI SP HTTP-Version CRLF

Method

1
2
3
4
5
6
7
8
9
10
Method = "OPTIONS"
| "GET"
| "HEAD"
| "POST"
| "PUT"
| "DELETE"
| "TRACE"
| "CONNECT"
| extension-method
extension-method = token

Request-URI

1
Request-URI = "*" | absoluteURI | abs_path | authority

例子:GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1

Request Header Fields

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
request-header = Accept
| Accept-Charset
| Accept-Encoding
| Accept-Language
| Authorization
| Expect
| From
| Host
| If-Match
| If-Modified-Since
| If-None-Match
| If-Range
| If-Unmodified-Since
| Max-Forwards
| Proxy-Authorization
| Range
| Referer
| TE
| User-Agent

Response

1
2
3
4
5
6
Response = Status-Line ;
*(( general-header
| response-header
| entity-header ) CRLF)
CRLF
[ message-body ]

Status-Line

1
Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF

Status Code and Reason Phrase

1
2
3
4
5
6
7
8
9
10
11
12
13
- 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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Status-Code =
| "100" ; Continue
| "101" ; Switching Protocols
| "200" ; OK
| "201" ; Created
| "202" ; Accepted
| "203" ; Non-Authoritative Information
| "204" ; No Content
| "205" ; Reset Content
| "206" ; Partial Content
| "300" ; Multiple Choices
| "301" ; Moved Permanently
| "302" ; Found
| "303" ; See Other
| "304" ; Not Modified
| "305" ; Use Proxy
| "307" ; Temporary Redirect
| "400" ; Bad Request
| "401" ; Unauthorized
| "402" ; Payment Required
| "403" ; Forbidden
| "404" ; Not Found
| "405" ; Method Not Allowed
| "406" ; Not Acceptable
| "407" ; Proxy Authentication Required
| "408" ; Request Time-out
| "409" ;: Conflict
| "410" ;: Gone
| "411" ;: Length Required
| "412" ;: Precondition Failed
| "413" ;: Request Entity Too Large
| "414" ;: Request-URI Too Large
| "415" ;: Unsupported Media Type
| "416" ;: Requested range not satisfiable
| "417" ;: Expectation Failed
| "500" ; Internal Server Error
| "501" ; Not Implemented
| "502" ; Bad Gateway
| "503" ; Service Unavailable
| "504" ; Gateway Time-out
| "505" ; HTTP Version not supported
| extension-code

Response Header Fields

1
2
3
4
5
6
7
8
9
response-header = Accept-Ranges
| Age
| ETag
| Location
| Proxy-Authenticate
| Retry-After
| Server
| Vary
| WWW-Authenticate
CATALOG
  1. 1. Request
    1. 1.0.1. Request-Line
    2. 1.0.2. Method
    3. 1.0.3. Request-URI
    4. 1.0.4. Request Header Fields
  • 2. Response
    1. 2.0.1. Status-Line
    2. 2.0.2. Status Code and Reason Phrase
    3. 2.0.3. Response Header Fields