; Collected rules from RFC 7230, Appendix B.
; https://tools.ietf.org/html/rfc7230#appendix-B

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-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 = *( ";" chunk-ext-name [ "=" chunk-ext-val ] )

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 ]

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 )
