HTTP/1.1 — 総集的 ABNF

【 このページは、 以前の HTTP/1.1 仕様を成す各文書 ( RFC 7230 〜 7235 ) の付録に掲載されている総集的文法( § Collected ABNF )を,ここに集約して掲載するものです。 】

ABNF リスト拡張 ( RFC 7230, § 7 )によるすべての規則は、 その節に従って,標準の ABNF 表記法に展開されている。

【 この和訳では、便宜上,原文の ABNF に編集上の手を加えている — リンクの追加 / 改行の仕方 / 重複の排除 / 他の仕様に定義される ABNF を独立の節(次節)に分離するなど。 】

他の仕様にて定義される規則

次に挙げる中核規則は、 [RFC5234] 付録 B.1 による定義から引用される:


ALPHA
	= %x41-5A
	/ %x61-7A
	; 英字( A-Z / a-z )
CR
	=  %x0D
	; carriage return
CRLF
	=  CR LF
	; Internet 標準の改行
CTL
	=  %x00-1F
	/ %x7F  
	; 制御文字
DIGIT
	=  %x30-39
	; 10 進数字( 0-9 )
DQUOTE
	=  %x22
	; 二重引用符( " )
HEXDIG
	=  DIGIT
	/ %x41-46
	/ %x61-66
	; 16 進数字( 0-9 / A-F / a-f )
HTAB
	=  %x09
	; 水平タブ
LF
	=  %x0A
	; line feed
OCTET
	=  %x00-FF
	; 任意の 8-bit データ単位(オクテット)
SP
	=  %x20
	; スペース
VCHAR
	=  %x21-7E
	; 任意の可視 [USASCII] 文字
CHAR
	=  %x01-7F
	; NUL を除く任意の [USASCII] 文字

次に挙げる規則は、 [RFC3986] にて,同じ名前の規則として定義される:

URI-reference
	; RFC 3986, § 4.1
absolute-URI
	; RFC 3986, § 4.3
authority
	; RFC 3986, § 3.2
fragment
	; RFC 3986, § 3.5
path-abempty
	; RFC 3986, § 3.3
port
	; RFC 3986, § 3.2.3
query
	; RFC 3986, § 3.4
relative-part
	; RFC 3986, § 4.2
scheme
	; RFC 3986, § 3.1
segment
	; RFC 3986, § 3.3
uri-host
	; RFC 3986, § 3.2.2

次に挙げる規則は、他の仕様にて定義される:

language-tag
	; RFC 5646, § 2.1
language-range
	; RFC 4647, § 2.1
mailbox
	; RFC 5322, § 3.4

RFC 7230 の総集的 ABNF

次に挙げる規則は、他所にて定義される:

URI-reference, absolute-URI, authority, fragment, path-abempty, port, query, relative-part, scheme, segment, uri-host
BWS
	= OWS

Connection
	= *( "," OWS ) connection-option
	  *( OWS "," [ OWS connection-option ] )

Content-Length
	= 1*DIGIT

HTTP-message
	= start-line
	  *( header-field CRLF ) CRLF
	  [ message-body ]
HTTP-name
	= %x48.54.54.50 ; HTTP
HTTP-version
	= HTTP-name "/" DIGIT "." DIGIT
Host
	= uri-host [ ":" port ]

OWS
	= *( SP / HTAB )

RWS
	= 1*( SP / HTAB )

TE
	= [ ( "," / t-codings ) *( OWS "," [ OWS t-codings ] ) ]
Trailer
	= *( "," OWS ) field-name
	  *( OWS "," [ OWS field-name ] )
Transfer-Encoding
	= *( "," OWS ) transfer-coding
	  *( OWS "," [ OWS transfer-coding ] )

Upgrade
	= *( "," OWS ) protocol
	  *( OWS "," [ OWS protocol ] )

Via
	= *( "," OWS )
	   ( received-protocol RWS received-by [ RWS comment ] )
	  *( OWS "," [ OWS ( received-protocol RWS received-by [ RWS comment ] ) ] )

absolute-form
	= absolute-URI
absolute-path
	= 1*( "/" segment )
asterisk-form
	= "*"
authority-form
	= authority
chunk
	= chunk-size [ chunk-ext ] CRLF chunk-data CRLF
chunk-data
	= 1*OCTET
chunk-ext
	= *( BWS ";" BWS chunk-ext-name [ BWS "=" BWS chunk-ext-val ] )
	; 挿入された 4 個の BWS は、正誤表#4825( Verified: 2016-10-07 )による修正
chunk-ext-name
	= token
chunk-ext-val
	= token
	/ quoted-string
chunk-size
	= 1*HEXDIG
chunked-body
	= *chunk last-chunk trailer-part CRLF
comment
	= "(" *( ctext / quoted-pair / comment ) ")"
connection-option
	= token
ctext
	= HTAB
	/ SP
	/ %x21-27 ; '!'-'''
	/ %x2A-5B ; '*'-'['
	/ %x5D-7E ; ']'-'~'
	/ obs-text

field-content
	= field-vchar [ 1*( SP / HTAB ) field-vchar ]
field-name
	= token
field-value
	= *( field-content / obs-fold )
field-vchar
	= VCHAR
	/ obs-text

header-field
	= field-name ":" OWS field-value OWS
http-URI
	= "http://" authority path-abempty
	  [ "?" query ] [ "#" fragment ]
	; [ "#" fragment ] の削除は、正誤表#4251( Verified: 2015-02-01 )による修正
https-URI
	= "https://" authority path-abempty
	  [ "?" query ] [ "#" fragment ]
	; 正誤表による修正(同上)

last-chunk
	= 1*"0" [ chunk-ext ] CRLF

message-body
	= *OCTET
method
	= token

obs-fold
	= CRLF 1*( SP / HTAB )
obs-text
	= %x80-FF
origin-form
	= absolute-path [ "?" query ]

partial-URI
	= relative-part [ "?" query ]
protocol
	= protocol-name [ "/" protocol-version ]
protocol-name
	= token
protocol-version
	= token
pseudonym
	= token

qdtext
	= HTAB
	/ SP
	/ "!"
	/ %x23-5B ; '#'-'['
	/ %x5D-7E ; ']'-'~'
	/ obs-text
quoted-pair
	= "\" ( HTAB / SP / VCHAR / obs-text )
quoted-string
	= DQUOTE *( qdtext / quoted-pair ) DQUOTE

rank
	= ( "0" [ "." *3DIGIT ] )
	/ ( "1" [ "." *3"0" ] )
reason-phrase
	= *( HTAB / SP / VCHAR / obs-text )
received-by
	= ( uri-host [ ":" port ] )
	/ pseudonym
received-protocol
	= [ protocol-name "/" ] protocol-version
request-line
	= method SP request-target SP HTTP-version CRLF
request-target
	= origin-form
	/ absolute-form
	/ authority-form
	/ asterisk-form

start-line
	= request-line
	/ status-line
status-code
	= 3DIGIT
status-line
	= HTTP-version SP status-code SP reason-phrase CRLF

t-codings
	= "trailers"
	/ ( transfer-coding [ t-ranking ] )
t-ranking
	= OWS ";" OWS "q=" rank
tchar
	= "!"
	/ "#"
	/ "$"
	/ "%"
	/ "&"
	/ "'"
	/ "*"
	/ "+"
	/ "-"
	/ "."
	/ "^"
	/ "_"
	/ "`"
	/ "|"
	/ "~"
	/ DIGIT
	/ ALPHA
token
	= 1*tchar
trailer-part
	= *( header-field CRLF )
transfer-coding
	= "chunked"
	/ "compress"
	/ "deflate"
	/ "gzip"
	/ transfer-extension
transfer-extension
	= token *( OWS ";" OWS transfer-parameter )
transfer-parameter
	= token BWS "=" BWS ( token / quoted-string )

RFC 7231 の総集的 ABNF

次に挙げる規則は、 [RFC7230] にて定義される:

BWS, OWS, RWS, URI-reference, absolute-URI, comment, field-name, partial-URI, quoted-string, token, method

次に挙げる規則も、他所にて定義される:

language-range, language-tag, mailbox
Accept
	= [ ( "," / ( media-range [ accept-params ] ) )
	  *( OWS "," [ OWS ( media-range [ accept-params ] ) ] ) ]
Accept-Charset
	= *( "," OWS ) ( ( charset / "*" ) [ weight ] )
	  *( OWS "," [ OWS ( ( charset / "*" ) [ weight ] ) ] )
Accept-Encoding
	= [ ( "," / ( codings [ weight ] ) )
	  *( OWS "," [ OWS ( codings [ weight ] ) ] ) ]
Accept-Language
	= *( "," OWS ) ( language-range [ weight ] )
	  *( OWS "," [ OWS ( language-range [ weight ] ) ] )
Allow
	= [ ( "," / method ) *( OWS "," [ OWS method ] ) ]

Content-Encoding
	= *( "," OWS ) content-coding
	  *( OWS "," [ OWS content-coding ] )
Content-Language
	= *( "," OWS ) language-tag
	  *( OWS "," [ OWS language-tag ] )
Content-Location
	= absolute-URI / partial-URI
Content-Type
	= media-type

Date
	= HTTP-date

Expect
	= "100-continue"

From
	= mailbox

GMT
	= %x47.4D.54 ; GMT

HTTP-date
	= IMF-fixdate
	/ obs-date

IMF-fixdate
	= day-name "," SP date1 SP time-of-day SP GMT

Location
	= URI-reference

Max-Forwards
	= 1*DIGIT

Referer
	= absolute-URI
	/ partial-URI
Retry-After
	= HTTP-date
	/ delay-seconds
Server
	= product *( RWS ( product / comment ) )

User-Agent
	= product *( RWS ( product / comment ) )

Vary
	= "*"
	/ ( *( "," OWS ) field-name *( OWS "," [ OWS field-name ] ) )

accept-ext
	= OWS ";" OWS token [ "=" ( token / quoted-string ) ]
accept-params
	= weight *accept-ext
asctime-date
	= day-name SP date3 SP time-of-day SP year

charset
	= token
codings
	= content-coding
	/ "identity"
	/ "*"
content-coding
	= token

date1
	= day SP month SP year
date2
	= day "-" month "-" 2DIGIT
date3
	= month SP ( 2DIGIT / ( SP DIGIT ) )
day
	= 2DIGIT
day-name
	= %x4D.6F.6E ; Mon
	/ %x54.75.65 ; Tue
	/ %x57.65.64 ; Wed
	/ %x54.68.75 ; Thu
	/ %x46.72.69 ; Fri
	/ %x53.61.74 ; Sat
	/ %x53.75.6E ; Sun
day-name-l
	= %x4D.6F.6E.64.61.79 ; Monday
	/ %x54.75.65.73.64.61.79 ; Tuesday
	/ %x57.65.64.6E.65.73.64.61.79 ; Wednesday
	/ %x54.68.75.72.73.64.61.79 ; Thursday
	/ %x46.72.69.64.61.79 ; Friday
	/ %x53.61.74.75.72.64.61.79 ; Saturday
	/ %x53.75.6E.64.61.79 ; Sunday
delay-seconds
	= 1*DIGIT

hour
	= 2DIGIT

media-range
	= ( "*/*" / ( type "/*" ) / ( type "/" subtype ) )
	  *( OWS  ";" OWS parameter )

media-type
	= type "/" subtype *( OWS ";" OWS parameter )
minute
	= 2DIGIT
month
	= %x4A.61.6E ; Jan
	/ %x46.65.62 ; Feb
	/ %x4D.61.72 ; Mar
	/ %x41.70.72 ; Apr
	/ %x4D.61.79 ; May
	/ %x4A.75.6E ; Jun
	/ %x4A.75.6C ; Jul
	/ %x41.75.67 ; Aug
	/ %x53.65.70 ; Sep
	/ %x4F.63.74 ; Oct
	/ %x4E.6F.76 ; Nov
	/ %x44.65.63 ; Dec

obs-date
	= rfc850-date
	/ asctime-date

parameter
	= token "=" ( token / quoted-string )
product
	= token [ "/" product-version ]
product-version
	= token
qvalue
	= ( "0" [ "." *3DIGIT ] )
	/ ( "1" [ "." *3"0" ] )

rfc850-date
	= day-name-l "," SP date2 SP time-of-day SP GMT

second
	= 2DIGIT
subtype
	= token

time-of-day
	= hour ":" minute ":" second
type
	= token

weight
	= OWS ";" OWS "q=" qvalue

year
	= 4DIGIT

RFC 7232 の総集的 ABNF

次に挙げる規則は、他所にて定義される:

OWS, obs-text, HTTP-date
ETag
	= entity-tag

If-Match
	= "*"
	/ ( *( "," OWS ) entity-tag *( OWS "," [ OWS entity-tag ] ) )
If-Modified-Since
	= HTTP-date
If-None-Match
	= "*"
	/ ( *( "," OWS ) entity-tag *( OWS "," [ OWS entity-tag ] ) )
If-Unmodified-Since
	= HTTP-date

Last-Modified
	= HTTP-date

entity-tag
	= [ weak ] opaque-tag
etagc
	= "!"
	/ %x23-7E ; '#'-'~'
	/ obs-text

opaque-tag
	= DQUOTE *etagc DQUOTE

weak
	= %x57.2F ; W/

RFC 7233 の総集的 ABNF

token から導出された すべての規則は、文字大小無視で比較されることに注意。 range-unitacceptable-ranges など。

次に挙げる規則は、他所にて定義される:

OWS, token, HTTP-date, entity-tag
Accept-Ranges
	= acceptable-ranges

Content-Range
	= byte-content-range
	/ other-content-range

If-Range
	= entity-tag
	/ HTTP-date

Range
	= byte-ranges-specifier
	/ other-ranges-specifier

acceptable-ranges
	= ( *( "," OWS ) range-unit *( OWS "," [ OWS range-unit ] ) )
	/ "none"

byte-content-range
	= bytes-unit SP ( byte-range-resp / unsatisfied-range )
byte-range
	= first-byte-pos "-" last-byte-pos
byte-range-resp
	= byte-range "/" ( complete-length / "*" )
byte-range-set
	= *( "," OWS )
	  ( byte-range-spec / suffix-byte-range-spec )
	  *( OWS "," [ OWS ( byte-range-spec / suffix-byte-range-spec ) ] )
byte-range-spec
	= first-byte-pos "-" [ last-byte-pos ]
byte-ranges-specifier
	= bytes-unit "=" byte-range-set
bytes-unit
	= "bytes"

complete-length
	= 1*DIGIT

first-byte-pos
	= 1*DIGIT

last-byte-pos
	= 1*DIGIT

other-content-range
	= other-range-unit SP other-range-resp
other-range-resp
	= *CHAR
other-range-set
	= 1*VCHAR
other-range-unit
	= token
other-ranges-specifier
	= other-range-unit "=" other-range-set

range-unit
	= bytes-unit
	/ other-range-unit

suffix-byte-range-spec
	= "-" suffix-length
suffix-length
	= 1*DIGIT

unsatisfied-range
	= "*/" complete-length

RFC 7234 の総集的 ABNF

次に挙げる規則は、他所にて定義される:

OWS, field-name, quoted-string, token, port, pseudonym, uri-host, HTTP-date
Age
	= delta-seconds

Cache-Control
	= *( "," OWS ) cache-directive *( OWS "," [ OWS cache-directive ] )

Expires
	= HTTP-date

Pragma
	= *( "," OWS ) pragma-directive *( OWS "," [ OWS pragma-directive ] )

Warning
	= *( "," OWS ) warning-value *( OWS "," [ OWS warning-value ] )

cache-directive
	= token [ "=" ( token / quoted-string ) ]

delta-seconds
	= 1*DIGIT

extension-pragma
	= token [ "=" ( token / quoted-string ) ]

pragma-directive
	= "no-cache" / extension-pragma

warn-agent
	= ( uri-host [ ":" port ] ) / pseudonym
warn-code
	= 3DIGIT
warn-date
	= DQUOTE HTTP-date DQUOTE
warn-text
	= quoted-string
warning-value
	= warn-code SP warn-agent SP warn-text [ SP warn-date ]

RFC 7235 の総集的 ABNF

次に挙げる規則は、他所にて定義される:

BWS, OWS, quoted-string, token
Authorization
	= credentials

Proxy-Authenticate
	= *( "," OWS ) challenge *( OWS "," [ OWS challenge ] )
Proxy-Authorization
	= credentials

WWW-Authenticate
	= *( "," OWS ) challenge *( OWS "," [ OWS challenge ] )

auth-param
	= token BWS "=" BWS ( token / quoted-string )
auth-scheme
	= token

challenge
	= auth-scheme [ 1*SP ( token68
	  / [ ( "," / auth-param ) *( OWS "," [ OWS auth-param ] ) ] ) ]
credentials
	= auth-scheme [ 1*SP ( token68
	  / [ ( "," / auth-param ) *( OWS "," [ OWS auth-param ] ) ] ) ]

token68
	= 1*( ALPHA / DIGIT / "-" / "." / "_" / "~" / "+" / "/" ) *"="