HTTP协议参数
HTTP版本
HTTP-Version = "HTTP" "/" 1*DIGIT "." 1*DIGIT
URI
http_URL = "http:" "//" host [ ":" port ] [ abs_path [ "?" query ]]
Date/Time Formats
允许使用的三种时间戳格式:
Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
HTTP-date = rfc1123-date | rfc850-date | asctime-date
rfc1123-date = wkday "," SP date1 SP time SP "GMT"
rfc850-date = weekday "," SP date2 SP time SP "GMT"
asctime-date = wkday SP date3 SP time SP 4DIGIT
date1 = 2DIGIT SP month SP 4DIGIT
; day month year (e.g., 02 Jun 1982)
date2 = 2DIGIT "-" month "-" 2DIGIT
; day-month-year (e.g., 02-Jun-82)
date3 = month SP ( 2DIGIT | ( SP 1DIGIT ))
; month day (e.g., Jun 2)
time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
; 00:00:00 - 23:59:59
wkday = "Mon" | "Tue" | "Wed"
| "Thu" | "Fri" | "Sat" | "Sun"
weekday = "Monday" | "Tuesday" | "Wednesday"
| "Thursday" | "Friday" | "Saturday" | "Sunday"
month = "Jan" | "Feb" | "Mar" | "Apr"
| "May" | "Jun" | "Jul" | "Aug"
| "Sep" | "Oct" | "Nov" | "Dec"
内容编码值
content-coding = token(大小写不敏感)
在头部的Accept-Encoding和Content-Encoding中使用,当前在IANA注册的token值为:
gzip:编码格式来自文件压缩程序
compress:
deflate: zlib格式
identity: 默认的编码值,只用于Accept-Encoding头部字段
传输编码
用于指示传输编码,或者在网络中保证entity-body安全传输,与内容编码的区别是message的属性而不是原始entity的。
大小写不敏感,HTTP/1.1在TE头部字段使用传输编码
transfer-coding = "chunked" | transfer-extension
transfer-extension = token *(";" parameter)
parameter = attribute "=" value
HTTP消息:
一般消息 = start-line
*(message-header CRLF)
CRLF
[ message-body ]
start-line = Request-Line | Status-Line
消息头部 = 普通头部 + 请求头部 + 应答头部 + 实体头部;
每个头部字段由名称:值组成,名称大小写不敏感,
普通头部 = Cache-Control
| Connection
| Date
| Pragma
| Trailer
| Transfer-Encoding
| Upgrade
| Via
| Warning
请求头部 = 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
应答头部 = Accept-Ranges
| Age
| ETag
| Location
| Proxy-Authenticate
| Retry-After
| Server
| Vary
| WWW-Authenticate
实体头部 = Allow
| Content-Encoding
| Content-Language
| Content-Length
| Content-Location
| Content-MD5
| Content-Range
| Content-Type
| Expires
| Last-Modified
| extension-header = message-header
消息体:用来装载请求或应答的实体body部分,message-body同entity-body的差异只在使用Transfer-Encoding头部字段发生;
message-body = entity-body
| <entity-body encoded as per Transfer-Encoding>
请求:
Request = Request-Line
*(( general-header
| request-header
| entity-header ) CRLF)
CRLF
[ message-body ]
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
Method:
"OPTIONS"
"GET"
"HEAD"
"POST"
"PUT"
"DELETE"
"TRACE"
"CONNECT"
extension-method = token
Request-URI = = "*" | absoluteURI | abs_path | authority
authority形式只在method为CONNECT下使用
应答:
Response = Status-Line
*(( general-header
| response-header
| entity-header ) CRLF)
CRLF
[ message-body ]
Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
Reason-Phrase = *<TEXT, excluding CR, LF>
实体
entity-body由HTTP请求和应答发送,按照entity-header中设置的格式编码,entity-body的类型
由Content-Type和Content-Encoding共同决定。
entity-body = *OCTET