HTTP1.1 Notes 8, Header Field Definitions

本文详细介绍了HTTP头部字段的种类及用途,包括请求头和响应头字段,如Accept、Content-Type等,这些字段对于理解HTTP通信过程至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[url]http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14[/url]

[b]Accept[/b]
The Accept request-header field can be used to specify certain media types which are acceptable for the response

Accept = "Accept" ":"
#( media-range [ accept-params ] )

media-range = ( "*/*"
| ( type "/" "*" )
| ( type "/" subtype )
) *( ";" parameter )
accept-params = ";" "q" "=" qvalue *( accept-extension )
accept-extension = ";" token [ "=" ( token | quoted-string ) ]

[b]Accept-Charset[/b]
The Accept-Charset request-header field can be used to indicate what character sets are acceptable for the response

Accept-Charset = "Accept-Charset" ":"
1#( ( charset | "*" )[ ";" "q" "=" qvalue ] )

[b]Accept-Encoding[/b]
The Accept-Encoding request-header field is similar to Accept, but restricts the content-codings that are acceptable in the response

Accept-Encoding = "Accept-Encoding" ":"

1#( codings [ ";" "q" "=" qvalue ] )
codings = ( content-coding | "*" )

[b]Accept-Language[/b]
The Accept-Language request-header field is similar to Accept, but restricts the set of natural languages that are preferred as a response to the request

Accept-Language = "Accept-Language" ":"
1#( language-range [ ";" "q" "=" qvalue ] )
language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )

[b]Accept-Ranges[/b]
The Accept-Ranges response-header field allows the server to indicate its acceptance of range requests for a resource

Accept-Ranges = "Accept-Ranges" ":" acceptable-ranges
acceptable-ranges = 1#range-unit | "none"

[b]Age[/b]
The Age response-header field conveys the sender's estimate of the amount of time since the response (or its revalidation) was generated at the origin server

Age = "Age" ":" age-value
age-value = delta-seconds

[b]Allow[/b]
The Allow entity-header field lists the set of methods supported by the resource identified by the Request-URI

Allow = "Allow" ":" #Method

[b]Authorization[/b]
A user agent that wishes to authenticate itself with a server--usually, but not necessarily, after receiving a 401 response--does so by including an Authorization request-header field with the request

Authorization = "Authorization" ":" credentials

[b]Cache-Control[/b]
The Cache-Control general-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain

Cache-Control = "Cache-Control" ":" 1#cache-directive

cache-directive = cache-request-directive
| cache-response-directive

cache-request-directive =
"no-cache"
| "no-store"
| "max-age" "=" delta-seconds
| "max-stale" [ "=" delta-seconds ]
| "min-fresh" "=" delta-seconds
| "no-transform"
| "only-if-cached"
| cache-extension

cache-response-directive =
"public"
| "private" [ "=" <"> 1#field-name <"> ]
| "no-cache" [ "=" <"> 1#field-name <"> ]
| "no-store"
| "no-transform"
| "must-revalidate"
| "proxy-revalidate"
| "max-age" "=" delta-seconds
| "s-maxage" "=" delta-seconds
| cache-extension

cache-extension = token [ "=" ( token | quoted-string ) ]

[b]Connection[/b]
The Connection general-header field allows the sender to specify options that are desired for that particular connection and MUST NOT be communicated by proxies over further connections

Connection = "Connection" ":" 1#(connection-token)
connection-token = token

[b]Content-Encoding[/b]
The Content-Encoding entity-header field is used as a modifier to the media-type

Content-Encoding = "Content-Encoding" ":" 1#content-coding

[b]Content-Language[/b]
The Content-Language entity-header field describes the natural language(s) of the intended audience for the enclosed entity

Content-Language = "Content-Language" ":" 1#language-tag

[b]Content-Length[/b]
The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET

Content-Length = "Content-Length" ":" 1*DIGIT

[b]Content-Location[/b]
The Content-Location entity-header field MAY be used to supply the resource location for the entity enclosed in the message when that entity is accessible from a location separate from the requested resource's URI

Content-Location = "Content-Location" ":"
( absoluteURI | relativeURI )

[b]Content-MD5[/b]
The Content-MD5 entity-header field, as defined in RFC 1864 [23], is an MD5 digest of the entity-body for the purpose of providing an end-to-end message integrity check (MIC) of the entity-body

Content-MD5 = "Content-MD5" ":" md5-digest
md5-digest = <base64 of 128 bit MD5 digest as per RFC 1864>

[b]Content-Range[/b]
The Content-Range entity-header is sent with a partial entity-body to specify where in the full entity-body the partial body should be applied

Content-Range = "Content-Range" ":" content-range-spec

content-range-spec = byte-content-range-spec
byte-content-range-spec = bytes-unit SP
byte-range-resp-spec "/"
( instance-length | "*" )

byte-range-resp-spec = (first-byte-pos "-" last-byte-pos)
| "*"
instance-length = 1*DIGIT

[b]Content-Type[/b]
The Content-Type entity-header field indicates the media type of the entity-body sent to the recipient or, in the case of the HEAD method, the media type that would have been sent had the request been a GET

Content-Type = "Content-Type" ":" media-type

[b]Date[/b]
The Date general-header field represents the date and time at which the message was originated, having the same semantics as orig-date in RFC 822

Date = "Date" ":" HTTP-date

[b]ETag[/b]
The ETag response-header field provides the current value of the entity tag for the requested variant

ETag = "ETag" ":" entity-tag

[b]Expect[/b]
The Expect request-header field is used to indicate that particular server behaviors are required by the client

Expect = "Expect" ":" 1#expectation

expectation = "100-continue" | expectation-extension
expectation-extension = token [ "=" ( token | quoted-string )
*expect-params ]
expect-params = ";" token [ "=" ( token | quoted-string ) ]

[b]Expires[/b]
The Expires entity-header field gives the date/time after which the response is considered stale

Expires = "Expires" ":" HTTP-date

[b]From[/b]
The From request-header field, if given, SHOULD contain an Internet e-mail address for the human user who controls the requesting user agent

From = "From" ":" mailbox

[b]Host[/b]
The Host request-header field specifies the Internet host and port number of the resource being requested, as obtained from the original URI given by the user or referring resource

Host = "Host" ":" host [ ":" port ]

[b]If-Match[/b]
The If-Match request-header field is used with a method to make it conditional

If-Match = "If-Match" ":" ( "*" | 1#entity-tag )

[b]If-Modified-Since[/b]
The If-Modified-Since request-header field is used with a method to make it conditional: if the requested variant has not been modified since the time specified in this field, an entity will not be returned from the server; instead, a 304 (not modified) response will be returned without any message-body

If-Modified-Since = "If-Modified-Since" ":" HTTP-date

[b]If-None-Match[/b]
The If-None-Match request-header field is used with a method to make it conditional

If-None-Match = "If-None-Match" ":" ( "*" | 1#entity-tag )

[b]If-Range[/b]
If a client has a partial copy of an entity in its cache, and wishes to have an up-to-date copy of the entire entity in its cache, it could use the Range request-header with a conditional GET

If-Range = "If-Range" ":" ( entity-tag | HTTP-date )

[b]If-Unmodified-Since[/b]
The If-Unmodified-Since request-header field is used with a method to make it conditional

If-Unmodified-Since = "If-Unmodified-Since" ":" HTTP-date

[b]Last-Modified[/b]
The Last-Modified entity-header field indicates the date and time at which the origin server believes the variant was last modified

Last-Modified = "Last-Modified" ":" HTTP-date

[b]Location[/b]
The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource

Location = "Location" ":" absoluteURI

[b]Max-Forwards[/b]
The Max-Forwards request-header field provides a mechanism with the TRACE and OPTIONS methods to limit the number of proxies or gateways that can forward the request to the next inbound server

Max-Forwards = "Max-Forwards" ":" 1*DIGIT

[b]Pragma[/b]
The Pragma general-header field is used to include implementation- specific directives that might apply to any recipient along the request/response chain

Pragma = "Pragma" ":" 1#pragma-directive
pragma-directive = "no-cache" | extension-pragma
extension-pragma = token [ "=" ( token | quoted-string ) ]

[b]Proxy-Authenticate[/b]
The Proxy-Authenticate response-header field MUST be included as part of a 407 (Proxy Authentication Required) response

Proxy-Authenticate = "Proxy-Authenticate" ":" 1#challenge

[b]Proxy-Authorization[/b]
The Proxy-Authorization request-header field allows the client to identify itself (or its user) to a proxy which requires authentication

Proxy-Authorization = "Proxy-Authorization" ":" credentials

[b]Range[/b]
HTTP retrieval requests using conditional or unconditional GET methods MAY request one or more sub-ranges of the entity, instead of the entire entity, using the Range request header, which applies to the entity returned as the result of the reques

Range = "Range" ":" ranges-specifier
ranges-specifier = byte-ranges-specifier
byte-ranges-specifier = bytes-unit "=" byte-range-set
byte-range-set = 1#( byte-range-spec | suffix-byte-range-spec )
byte-range-spec = first-byte-pos "-" [last-byte-pos]
first-byte-pos = 1*DIGIT
last-byte-pos = 1*DIGIT
suffix-byte-range-spec = "-" suffix-length
suffix-length = 1*DIGIT

[b]Referer[/b]
The Referer[sic] request-header field allows the client to specify, for the server's benefit, the address (URI) of the resource from which the Request-URI was obtained

Referer = "Referer" ":" ( absoluteURI | relativeURI )

[b]Retry-After[/b]
The Retry-After response-header field can be used with a 503 (Service Unavailable) response to indicate how long the service is expected to be unavailable to the requesting client

Retry-After = "Retry-After" ":" ( HTTP-date | delta-seconds )

[b]Server[/b]
The Server response-header field contains information about the software used by the origin server to handle the request

Server = "Server" ":" 1*( product | comment )

[b]TE[/b]
The TE request-header field indicates what extension transfer-codings it is willing to accept in the response and whether or not it is willing to accept trailer fields in a chunked transfer-coding

TE = "TE" ":" #( t-codings )
t-codings = "trailers" | ( transfer-extension [ accept-params ] )

[b]Trailer[/b]
The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer-coding

Trailer = "Trailer" ":" 1#field-name

[b]Transfer-Encoding[/b]
The Transfer-Encoding general-header field indicates what (if any) type of transformation has been applied to the message body in order to safely transfer it between the sender and the recipient

Transfer-Encoding = "Transfer-Encoding" ":" 1#transfer-coding

[b]Upgrade[/b]
The Upgrade general-header allows the client to specify what additional communication protocols it supports and would like to use if the server finds it appropriate to switch protocols

Upgrade = "Upgrade" ":" 1#product

[b]User-Agent[/b]
The User-Agent request-header field contains information about the user agent originating the request

User-Agent = "User-Agent" ":" 1*( product | comment )

[b]Vary[/b]
The Vary field value indicates the set of request-header fields that fully determines, while the response is fresh, whether a cache is permitted to use the response to reply to a subsequent request without revalidation

Vary = "Vary" ":" ( "*" | 1#field-name )

[b]Via[/b]
The Via general-header field MUST be used by gateways and proxies to indicate the intermediate protocols and recipients between the user agent and the server on requests, and between the origin server and the client on responses

Via = "Via" ":" 1#( received-protocol received-by [ comment ] )
received-protocol = [ protocol-name "/" ] protocol-version
protocol-name = token
protocol-version = token
received-by = ( host [ ":" port ] ) | pseudonym
pseudonym = token

[b]Warning[/b]
The Warning general-header field is used to carry additional information about the status or transformation of a message which might not be reflected in the message

Warning = "Warning" ":" 1#warning-value

warning-value = warn-code SP warn-agent SP warn-text
[SP warn-date]

warn-code = 3DIGIT
warn-agent = ( host [ ":" port ] ) | pseudonym
; the name or pseudonym of the server adding
; the Warning header, for use in debugging
warn-text = quoted-string
warn-date = <"> HTTP-date <">

[b]WWW-Authenticate[/b]
The WWW-Authenticate response-header field MUST be included in 401 (Unauthorized) response messages

WWW-Authenticate = "WWW-Authenticate" ":" 1#challenge

太多了,足足47个header filed,细节以后遇到再来看吧
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值