forked from avsm/ocaml-abnf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
http.abnf
211 lines (211 loc) · 9.91 KB
/
http.abnf
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
LWS = [CRLF] 1*( SP / HTAB )
tspecials = "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / DQUOTE / "/" / "[" / "]" / "?" / "=" / "{" / "}" / SP / HTAB
token = 1*<any CHAR except CTL / tspecials >
comment = "(" *( ctext / comment ) ")"
ctext = <any TEXT except "(" / ")">
quoted-string = ( DQUOTE *( qdtext ) DQUOTE )
qdtext = <any TEXT except DQUOTE>
quoted-pair = "\" CHAR
HTTP-Version = "HTTP" "/" 1*DIGIT "." 1*DIGIT
URI = ( absoluteURI / relativeURI ) ["#" fragment]
absoluteURI = scheme ":" *( uchar / reserved )
relativeURI = net_path / abs_path / rel_path
net_path = "//" net_loc [abs_path]
abs_path = "/" rel_path
rel_path = [path] [";" params] ["?" query]
path = fsegment *( "/" segment )
fsegment = 1*pchar
segment = *pchar
params = param *( ";" param )
param = *( pchar / "/" )
scheme = 1*( ALPHA / DIGIT / "+" / "-" / "." )
net_loc = *( pchar / ";" / "?" )
query = *( uchar / reserved )
fragment = *( uchar / reserved )
pchar = uchar / ":" / "@" / "&" / "=" / "+"
uchar = unreserved / escape
unreserved = ALPHA / DIGIT / safe / extra / national
escape = "%" HEXDIGIT HEXDIGIT
reserved = ";" / "/" / "?" / ":" / "@" / "&" / "=" / "+"
extra = "!" / "*" / "'" / "(" / ")" / ","
safe = "$" / "-" / "_" / "."
unsafe = CTL / SP / DQUOTE / "#" / "%" / "<" / ">"
national = <any OCTET except ALPHA / DIGIT / reserved / extra / safe / unsafe>
http_URL = "http:" "//" host [":" port] [abs_path]
host = <any OCTET except ":" / "/">
port = *DIGIT
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
date2 = 2DIGIT "-" month "-" 2DIGIT
date3 = month SP ( 2DIGIT / ( SP 1DIGIT ) )
time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
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"
delta-seconds = 1*DIGIT
charset = token
content-coding = token
transfer-coding = "chunked" / transfer-extension
transfer-extension = token
Chunked-Body = *chunk "0" CRLF footer CRLF
chunk = chunk-size [chunk-ext] CRLF chunk-data CRLF
hex-no-zero = <any HEXDIGIT except "0">
chunk-size = hex-no-zero *HEXDIGIT
chunk-ext = *( ";" chunk-ext-name ["=" chunk-ext-value] )
chunk-ext-name = token
chunk-ext-value = token / quoted-string
chunk-data = chunk-size ( OCTET )
footer = *entity-header
media-type = type "/" subtype *( ";" parameter )
type = token
subtype = token
parameter = attribute "=" value
attribute = token
value = token / quoted-string
product = token ["/" product-version]
product-version = token
qvalue = ( "0" ["." 0*3DIGIT] ) / ( "1" ["." 0*3( "0" )] )
language-tag = primary-tag *( "-" subtag )
primary-tag = 1*8ALPHA
subtag = 1*8ALPHA
entity-tag = [weak] opaque-tag
weak = "W/"
opaque-tag = quoted-string
range-unit = bytes-unit / other-range-unit
bytes-unit = "bytes"
other-range-unit = token
HTTP-message = Request / Response
generic-message = start-line *message-header CRLF [message-body]
start-line = Request-Line / Status-Line
message-header = field-name ":" [field-value] CRLF
field-name = token
field-value = *( field-content / LWS )
field-content = <any OCTET except LWS>
message-body = entity-body
general-header = Cache-Control / Connection / Date / Pragma / Transfer-Encoding / Upgrade / Via
Request = Request-Line / *( general-header / request-header / entity-header ) CRLF [message-body]
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
Method = "OPTIONS" / "GET" / "HEAD" / "POST" / "PUT" / "DELETE" / "TRACE" / extension-method
extension-method = token
Request-URI = "*" / absoluteURI / abs_path
request-header = Accept / Accept-Charset / Accept-Encoding / Accept-Language / Authorization / From / Host / If-Modified-Since / If-Match / If-None-Match / If-Range / If-Unmodified-Since / Max-Forwards / Proxy-Authorization / Range / Referer / User-Agent
Response = Status-Line *( general-header / response-header / entity-header ) CRLF [message-body]
Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
Status-Code = 3DIGIT
Reason-Phrase = *<any TEXT except CR / LF>
response-header = Age / Location / Proxy-Authenticate / Public / Retry-After / Server / Vary / Warning / WWW-Authenticate / MIME-Version / Content-Version / Derived-From / Link
entity-header = Allow / Content-Base / Content-Encoding / Content-Language / Content-Length / Content-Location / Content-MD5 / Content-Range / Content-Type / ETag / Expires / Last-Modified / extension-header
extension-header = message-header
entity-body = *OCTET
auth-scheme = token
auth-param = token "=" quoted-string
challenge = auth-scheme 1*SP realm *( "," auth-param )
realm = "realm" "=" realm-value
realm-value = quoted-string
credentials = basic-credentials / auth-scheme #auth-param
basic-credentials = "Basic" SP basic-cookie
base64 = *(4base64-char) [base64-terminal]
base64-char = ALPHA / DIGIT / "+" / "/"
base64-terminal = (2base64-char "==") / (3base64-char "=")
basic-cookie = base64
user-pass = userid ":" password
userid = *<any TEXT except ":">
password = *TEXT
Accept = "Accept" ":" #( media-range [accept-params] )
media-range = ( "*/*" / ( type "/" "*" ) / ( type "/" subtype ) ) *( ";" parameter )
accept-params = ";" "q" "=" qvalue *( accept-extension )
accept-extension = ";" token ["=" ( token / quoted-string )]
Accept-Charset = "Accept-Charset" ":" 1#( charset [";" "q" "=" qvalue] )
Accept-Encoding = "Accept-Encoding" ":" #( content-coding )
Accept-Language = "Accept-Language" ":" 1#( language-range [";" "q" "=" qvalue] )
language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) / "*" )
Accept-Ranges = "Accept-Ranges" ":" acceptable-ranges
acceptable-ranges = 1#range-unit / "none"
Age = "Age" ":" age-value
age-value = delta-seconds
Allow = "Allow" ":" 1#Method
Authorization = "Authorization" ":" credentials
Cache-Control = "Cache-Control" ":" 1#cache-directive
cache-directive = cache-request-directive / cache-response-directive
cache-request-directive = "no-cache" ["=" DQUOTE 1#field-name DQUOTE] / "no-store" / "max-age" "=" delta-seconds / "max-stale" ["=" delta-seconds] / "min-fresh" "=" delta-seconds / "only-if-cached" / cache-extension
cache-response-directive = "public" / "private" ["=" DQUOTE 1#field-name DQUOTE] / "no-cache" ["=" DQUOTE 1#field-name DQUOTE] / "no-store" / "no-transform" / "must-revalidate" / "proxy-revalidate" / "max-age" "=" delta-seconds / cache-extension
cache-extension = token ["=" ( token / quoted-string )]
Connection = Connection-header
Connection-header = "Connection" ":" 1#( connection-token )
connection-token = token
Content-Base = "Content-Base" ":" absoluteURI
Content-Encoding = "Content-Encoding" ":" 1#content-coding
Content-Language = "Content-Language" ":" 1#language-tag
Content-Length = "Content-Length" ":" 1*DIGIT
Content-Location = "Content-Location" ":" ( absoluteURI / relativeURI )
Content-MD5 = "Content-MD5" ":" md5-digest
md5-digest = base64
Content-Range = "Content-Range" ":" content-range-spec
content-range-spec = byte-content-range-spec
byte-content-range-spec = bytes-unit SP first-byte-pos "-" last-byte-pos "/" entity-length
entity-length = 1*DIGIT
Content-Type = "Content-Type" ":" media-type
Date = "Date" ":" HTTP-date
ETag = "ETag" ":" entity-tag
Expires = "Expires" ":" HTTP-date
From = "From" ":" mailbox
mailbox = TEXT
Host = "Host" ":" host [":" port]
If-Modified-Since = "If-Modified-Since" ":" HTTP-date
If-Match = "If-Match" ":" ( "*" / 1#entity-tag )
If-None-Match = "If-None-Match" ":" ( "*" / 1#entity-tag )
If-Range = "If-Range" ":" ( entity-tag / HTTP-date )
If-Unmodified-Since = "If-Unmodified-Since" ":" HTTP-date
Last-Modified = "Last-Modified" ":" HTTP-date
Location = "Location" ":" absoluteURI
Max-Forwards = "Max-Forwards" ":" 1*DIGIT
Pragma = "Pragma" ":" 1#pragma-directive
pragma-directive = "no-cache" / extension-pragma
extension-pragma = token ["=" ( token / quoted-string )]
Proxy-Authenticate = "Proxy-Authenticate" ":" challenge
Proxy-Authorization = "Proxy-Authorization" ":" credentials
Public = "Public" ":" 1#Method
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
Range = "Range" ":" ranges-specifier
Referer = "Referer" ":" ( absoluteURI / relativeURI )
Retry-After = "Retry-After" ":" ( HTTP-date / delta-seconds )
Server = "Server" ":" 1*( product / comment )
Transfer-Encoding = "Transfer-Encoding" ":" 1#transfer-coding
Upgrade = "Upgrade" ":" 1#product
User-Agent = "User-Agent" ":" 1*( product / comment )
Vary = "Vary" ":" ( "*" / 1#field-name )
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
Warning = "Warning" ":" 1#warning-value
warning-value = warn-code SP warn-agent SP warn-text
warn-code = 2DIGIT
warn-agent = ( host [":" port] ) / pseudonym
warn-text = quoted-string
WWW-Authenticate = "WWW-Authenticate" ":" 1#challenge
MIME-Version = "MIME-Version" ":" 1*DIGIT "." 1*DIGIT
Content-Version = "Content-Version" ":" quoted-string
Derived-From = "Derived-From" ":" quoted-string
Link = "Link" ":" #( "<" URI ">" *( ";" link-param ) )
link-param = ( ( "rel" "=" relationship ) / ( "rev" "=" relationship ) / ( "title" "=" quoted-string ) / ( "anchor" "=" DQUOTE URI DQUOTE ) / ( link-extension ) )
link-extension = token ["=" ( token / quoted-string )]
relationship = sgml-name / ( DQUOTE sgml-name *( SP sgml-name ) DQUOTE )
sgml-name = ALPHA *( ALPHA / DIGIT / "." / "-" )
URI-header = "URI" ":" 1#( "<" URI ">" )
Keep-Alive-header = "Keep-Alive" ":" 0#keepalive-param
keepalive-param = param-name "=" value
param-name = *TEXT
TEXT = <any OCTET except CTL>