Skip to content

Instantly share code, notes, and snippets.

@mnot
Last active November 11, 2019 03:22
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnot/22b4e82ae3ea44f760cd4806c1ebcd56 to your computer and use it in GitHub Desktop.
Save mnot/22b4e82ae3ea44f760cd4806c1ebcd56 to your computer and use it in GitHub Desktop.
Railroad diagrams of HTTP semantics
# Generated from the ABNF at <https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#collected.abnf>
# using <https://github.com/katef/kgt>
Accept:
,---------------------------------------------------------------------------------------------------------------------------.
| |
||--^--v----------------- "," ------------------>--v------------------------------------------------------------------------->-->--||
| | | |
| ,-------------------. | | ,-----------------------------------------------. |
| | | | | | | |
`-- media-range --^-- accept-params -->--' | | ,-------------------. | |
| | | | | |
`-->-- OWS -- "," --^-- OWS -- media-range --^-- accept-params -->-->--v--'
| |
`---------------------------------<---------------------------------'
Accept-Charset:
,------------.
| |
||--v---------------------->--v-- charset -->--^-- weight -->--v-------------------------------------------------------------------->--||
| | | | | |
`-->-- "," -- OWS --v--' `---- "*" ----' | ,------------------------------------------. |
| | | | | |
`-------<--------' | | ,------------. | |
| | | | | |
`-->-- OWS -- "," --^-- OWS --v-- charset -->--^-- weight -->-->--v--'
| | | |
| `---- "*" ----' |
| |
`------------------------------<-------------------------------'
Accept-Encoding:
,-----------------------------------------------------------------------------------------------------.
| |
||--^--v------------ "," ------------>--v-------------------------------------------------------------->-->--||
| | | |
| ,------------. | | ,------------------------------------. |
| | | | | | | |
`-- codings --^-- weight -->--' | | ,------------. | |
| | | | | |
`-->-- OWS -- "," --^-- OWS -- codings --^-- weight -->-->--v--'
| |
`---------------------------<----------------------------'
Accept-Language:
,------------.
| |
||--v---------------------->-- language-range --^-- weight -->--v--------------------------------------------------------------------->--||
| | | |
`-->-- "," -- OWS --v--' | ,-------------------------------------------. |
| | | | | |
`-------<--------' | | ,------------. | |
| | | | | |
`-->-- OWS -- "," --^-- OWS -- language-range --^-- weight -->-->--v--'
| |
`-------------------------------<-------------------------------'
Accept-Ranges:
||-- acceptable-ranges --||
Allow:
,-------------------------------------------------------------------.
| |
||--^--v--- "," ---->--v--------------------------------------------->-->--||
| | | |
`-- method --' | ,-------------------. |
| | | |
`-->-- OWS -- "," --^-- OWS -- method -->--v--'
| |
`-------------------<-------------------'
Authentication-Info:
,---------------------------------------------------------------------------.
| |
||--^--v----- "," ------>--v------------------------------------------------->-->--||
| | | |
`-- auth-param --' | ,-----------------------. |
| | | |
`-->-- OWS -- "," --^-- OWS -- auth-param -->--v--'
| |
`---------------------<---------------------'
Authorization:
||-- credentials --||
BWS:
||-- OWS --||
Content-Encoding:
||--v---------------------->-- content-coding --v----------------------------------------------------->--||
| | | |
`-->-- "," -- OWS --v--' | ,---------------------------. |
| | | | | |
`-------<--------' `-->-- OWS -- "," --^-- OWS -- content-coding -->--v--'
| |
`-----------------------<-----------------------'
Content-Language:
||--v---------------------->-- language-tag --v--------------------------------------------------->--||
| | | |
`-->-- "," -- OWS --v--' | ,-------------------------. |
| | | | | |
`-------<--------' `-->-- OWS -- "," --^-- OWS -- language-tag -->--v--'
| |
`----------------------<----------------------'
Content-Length:
||-->-- DIGIT --v--||
| |
`-----<-----'
Content-Location:
||--v-- absolute-URI -->--||
| |
`-- partial-URI ---'
Content-Range:
||--v-- byte-content-range --->--||
| |
`-- other-content-range --'
Content-Type:
||-- media-type --||
Date:
||-- HTTP-date --||
ETag:
||-- entity-tag --||
Expect:
||-- "100-continue" --||
From:
||-- mailbox --||
GMT:
||-- "GMT" --||
HTTP-date:
||--v-- IMF-fixdate -->--||
| |
`--- obs-date ----'
Host:
,-----------------.
| |
||-- uri-host --^-- ":" -- port -->--||
IMF-fixdate:
||-- day-name -- "," -- SP -- date1 -- SP -- time-of-day -- SP -- GMT --||
If-Match:
||--v--------------------------------------------- "*" --------------------------------------------->--||
| |
`--v---------------------->-- entity-tag --v------------------------------------------------->--'
| | | |
`-->-- "," -- OWS --v--' | ,-----------------------. |
| | | | | |
`-------<--------' `-->-- OWS -- "," --^-- OWS -- entity-tag -->--v--'
| |
`---------------------<---------------------'
If-Modified-Since:
||-- HTTP-date --||
If-None-Match:
||--v--------------------------------------------- "*" --------------------------------------------->--||
| |
`--v---------------------->-- entity-tag --v------------------------------------------------->--'
| | | |
`-->-- "," -- OWS --v--' | ,-----------------------. |
| | | | | |
`-------<--------' `-->-- OWS -- "," --^-- OWS -- entity-tag -->--v--'
| |
`---------------------<---------------------'
If-Range:
||--v-- entity-tag -->--||
| |
`-- HTTP-date ---'
If-Unmodified-Since:
||-- HTTP-date --||
Last-Modified:
||-- HTTP-date --||
Location:
||-- URI-reference --||
Max-Forwards:
||-->-- DIGIT --v--||
| |
`-----<-----'
OWS:
||-->----------------v--||
| |
`--<--- SP ---v--'
| |
`-- HTAB --'
Proxy-Authenticate:
||--v---------------------->-- challenge --v------------------------------------------------>--||
| | | |
`-->-- "," -- OWS --v--' | ,----------------------. |
| | | | | |
`-------<--------' `-->-- OWS -- "," --^-- OWS -- challenge -->--v--'
| |
`--------------------<---------------------'
Proxy-Authentication-Info:
,---------------------------------------------------------------------------.
| |
||--^--v----- "," ------>--v------------------------------------------------->-->--||
| | | |
`-- auth-param --' | ,-----------------------. |
| | | |
`-->-- OWS -- "," --^-- OWS -- auth-param -->--v--'
| |
`---------------------<---------------------'
Proxy-Authorization:
||-- credentials --||
RWS:
||-->--v--- SP --->--v--||
| | | |
| `-- HTAB --' |
| |
`-------<--------'
Range:
||--v-- byte-ranges-specifier --->--||
| |
`-- other-ranges-specifier --'
Referer:
||--v-- absolute-URI -->--||
| |
`-- partial-URI ---'
Retry-After:
||--v---- HTTP-date ---->--||
| |
`-- delay-seconds --'
Server:
||-- product --v-------------------------------->--||
| |
`-->-- RWS --v-- product -->--v--'
| | | |
| `-- comment --' |
| |
`------------<-------------'
Trailer:
||--v---------------------->-- field-name --v------------------------------------------------->--||
| | | |
`-->-- "," -- OWS --v--' | ,-----------------------. |
| | | | | |
`-------<--------' `-->-- OWS -- "," --^-- OWS -- field-name -->--v--'
| |
`---------------------<---------------------'
User-Agent:
||-- product --v-------------------------------->--||
| |
`-->-- RWS --v-- product -->--v--'
| | | |
| `-- comment --' |
| |
`------------<-------------'
Vary:
||--v--------------------------------------------- "*" --------------------------------------------->--||
| |
`--v---------------------->-- field-name --v------------------------------------------------->--'
| | | |
`-->-- "," -- OWS --v--' | ,-----------------------. |
| | | | | |
`-------<--------' `-->-- OWS -- "," --^-- OWS -- field-name -->--v--'
| |
`---------------------<---------------------'
Via:
,--------------------.
| |
||--v---------------------->-- received-protocol -- RWS -- received-by --^-- RWS -- comment -->--v------------------------------------------------------------------------------------------------------>--||
| | | |
`-->-- "," -- OWS --v--' | ,----------------------------------------------------------------------------. |
| | | | | |
`-------<--------' | | ,--------------------. | |
| | | | | |
`-->-- OWS -- "," --^-- OWS -- received-protocol -- RWS -- received-by --^-- RWS -- comment -->-->--v--'
| |
`-----------------------------------------------<------------------------------------------------'
WWW-Authenticate:
||--v---------------------->-- challenge --v------------------------------------------------>--||
| | | |
`-->-- "," -- OWS --v--' | ,----------------------. |
| | | | | |
`-------<--------' `-->-- OWS -- "," --^-- OWS -- challenge -->--v--'
| |
`--------------------<---------------------'
absolute-path:
||-->-- "/" -- segment --v--||
| |
`---------<----------'
accept-ext:
,--------------------------------.
| |
||-- OWS -- ";" -- OWS -- token --^-- "=" --v------ token ------>-->--||
| |
`-- quoted-string --'
accept-params:
||-- weight -->----------------v--||
| |
`-- accept-ext --'
acceptable-ranges:
||--v--v---------------------->-- range-unit --v------------------------------------------------->-->--||
| | | | | |
| `-->-- "," -- OWS --v--' | ,-----------------------. | |
| | | | | | | |
| `-------<--------' `-->-- OWS -- "," --^-- OWS -- range-unit -->--v--' |
| | | |
| `---------------------<---------------------' |
| |
`------------------------------------------- "none" --------------------------------------------'
asctime-date:
||-- day-name -- SP -- date3 -- SP -- time-of-day -- SP -- year --||
auth-param:
||-- token -- BWS -- "=" -- BWS --v------ token ------>--||
| |
`-- quoted-string --'
auth-scheme:
||-- token --||
byte-content-range:
||-- bytes-unit -- SP --v--- byte-range-resp --->--||
| |
`-- unsatisfied-range --'
byte-range:
||-- first-byte-pos -- "-" -- last-byte-pos --||
byte-range-resp:
||-- byte-range -- "/" --v-- complete-length -->--||
| |
`-------- "*" --------'
byte-range-set:
||--v---------------------->--v----- byte-range-spec ------>--v------------------------------------------------------------------->--||
| | | | | |
`-->-- "," -- OWS --v--' `-- suffix-byte-range-spec --' | ,-----------------------------------------. |
| | | | | |
`-------<--------' `-->-- OWS -- "," --^-- OWS --v----- byte-range-spec ------>-->--v--'
| | | |
| `-- suffix-byte-range-spec --' |
| |
`------------------------------<------------------------------'
byte-range-spec:
,-------------------.
| |
||-- first-byte-pos -- "-" --^-- last-byte-pos -->--||
byte-ranges-specifier:
||-- bytes-unit -- "=" -- byte-range-set --||
bytes-unit:
||-- "bytes" --||
challenge:
,---------------------------------------------------------------------------------------------.
| |
||-- auth-scheme --^-->-- SP --v--v--------------------------------- token68 --------------------------------->-->--||
| | | |
`---<----' `--v----- "," ------>--v------------------------------------------------->--'
| | | |
`-- auth-param --' | ,-----------------------. |
| | | |
`-->-- OWS -- "," --^-- OWS -- auth-param -->--v--'
| |
`---------------------<---------------------'
charset:
||-- token --||
codings:
||--v-- content-coding -->--||
| |
>---- "identity" ----^
| |
`------- "*" --------'
comment:
||-- "(" -->-----------------------v-- ")" --||
| |
`--<----- ctext -----v--'
| |
^-- quoted-pair --<
| |
`---- comment ----'
complete-length:
||-->-- DIGIT --v--||
| |
`-----<-----'
content-coding:
||-- token --||
credentials:
,---------------------------------------------------------------------------------------------.
| |
||-- auth-scheme --^-->-- SP --v--v--------------------------------- token68 --------------------------------->-->--||
| | | |
`---<----' `--v----- "," ------>--v------------------------------------------------->--'
| | | |
`-- auth-param --' | ,-----------------------. |
| | | |
`-->-- OWS -- "," --^-- OWS -- auth-param -->--v--'
| |
`---------------------<---------------------'
ctext:
||--v---- HTAB ---->--||
| |
>----- SP -----^
| |
>---- "!" -----^
| |
| : |
| |
>---- "'" -----^
| |
>---- "*" -----^
| |
| : |
| |
>---- "[" -----^
| |
>---- "]" -----^
| |
| : |
| |
>---- "~" -----^
| |
`-- obs-text --'
date1:
||-- day -- SP -- month -- SP -- year --||
date2:
||-- day -- "-" -- month -- "-" -->----- DIGIT ------v--||
| |
`--(exactly once)--'
date3:
||-- month -- SP --v-->----- DIGIT ------v-->--||
| | | |
| `--(exactly once)--' |
| |
`----- SP -- DIGIT ------'
day:
||-->----- DIGIT ------v--||
| |
`--(exactly once)--'
day-name:
||--v-- "Mon" -->--||
| |
>-- "Tue" --^
| |
>-- "Wed" --^
| |
>-- "Thu" --^
| |
>-- "Fri" --^
| |
>-- "Sat" --^
| |
`-- "Sun" --'
day-name-l:
||--v--- "Monday" ---->--||
| |
>--- "Tuesday" ---^
| |
>-- "Wednesday" --^
| |
>-- "Thursday" ---^
| |
>--- "Friday" ----^
| |
>-- "Saturday" ---^
| |
`--- "Sunday" ----'
delay-seconds:
||-->-- DIGIT --v--||
| |
`-----<-----'
entity-tag:
,----------.
| |
||--^-- weak -->-- opaque-tag --||
etagc:
||--v---- "!" ----->--||
| |
>---- "#" -----^
| |
| : |
| |
>---- "~" -----^
| |
`-- obs-text --'
field-content:
,-------------------------------------.
| |
||-- field-vchar --^-->--v--- SP --->--v-- field-vchar -->--||
| | | |
| `-- HTAB --' |
| |
`-------<--------'
field-name:
||-- token --||
field-value:
||-->-------------------------v--||
| |
`--<-- field-content --v--'
| |
`---- obs-fold -----'
field-vchar:
||--v--- VCHAR ---->--||
| |
`-- obs-text --'
first-byte-pos:
||-->-- DIGIT --v--||
| |
`-----<-----'
hour:
||-->----- DIGIT ------v--||
| |
`--(exactly once)--'
http-URI:
,------------------.
| |
||-- "http://" -- authority -- path-abempty --^-- "?" -- query -->--||
https-URI:
,------------------.
| |
||-- "https://" -- authority -- path-abempty --^-- "?" -- query -->--||
last-byte-pos:
||-->-- DIGIT --v--||
| |
`-----<-----'
media-range:
||--v---------- "*/*" ----------->--v------------------------------------------>--||
| | | |
>------- type -- "/*" -------^ `-->-- OWS -- ";" -- OWS -- parameter --v--'
| | | |
`-- type -- "/" -- subtype --' `-----------------<------------------'
media-type:
||-- type -- "/" -- subtype --v------------------------------------------>--||
| |
`-->-- OWS -- ";" -- OWS -- parameter --v--'
| |
`-----------------<------------------'
method:
||-- token --||
minute:
||-->----- DIGIT ------v--||
| |
`--(exactly once)--'
month:
||--v-- "Jan" -->--||
| |
>-- "Feb" --^
| |
>-- "Mar" --^
| |
>-- "Apr" --^
| |
>-- "May" --^
| |
>-- "Jun" --^
| |
>-- "Jul" --^
| |
>-- "Aug" --^
| |
>-- "Sep" --^
| |
>-- "Oct" --^
| |
>-- "Nov" --^
| |
`-- "Dec" --'
obs-date:
||--v-- rfc850-date --->--||
| |
`-- asctime-date --'
obs-text:
||--v-- "\x80" -->--||
| |
| : |
| |
`-- "\xfe" --'
opaque-tag:
||-- DQUOTE -->-----------v-- DQUOTE --||
| |
`-- etagc --'
other-content-range:
||-- other-range-unit -- SP -- other-range-resp --||
other-range-resp:
||-->-----------v--||
| |
`-- VCHAR --'
other-range-set:
||-->-- VCHAR --v--||
| |
`-----<-----'
other-range-unit:
||-- token --||
other-ranges-specifier:
||-- other-range-unit -- "=" -- other-range-set --||
parameter:
||-- token -- "=" --v------ token ------>--||
| |
`-- quoted-string --'
partial-URI:
,------------------.
| |
||-- relative-part --^-- "?" -- query -->--||
product:
,----------------------------.
| |
||-- token --^-- "/" -- product-version -->--||
product-version:
||-- token --||
pseudonym:
||-- token --||
qdtext:
||--v---- HTAB ---->--||
| |
>----- SP -----^
| |
>---- "!" -----^
| |
>---- "#" -----^
| |
| : |
| |
>---- "[" -----^
| |
>---- "]" -----^
| |
| : |
| |
>---- "~" -----^
| |
`-- obs-text --'
quoted-pair:
||-- "\\" --v---- HTAB ---->--||
| |
>----- SP -----^
| |
>--- VCHAR ----^
| |
`-- obs-text --'
quoted-string:
||-- DQUOTE -->-----------------------v-- DQUOTE --||
| |
`--<---- qdtext -----v--'
| |
`-- quoted-pair --'
qvalue:
,--------------------------------.
| |
||--v-- "0" --^-- "." -->-------------------v-->-->--||
| | | |
| `------ DIGIT ------' |
| |
| (up to 3 times) |
| |
| ,--------------------------------. |
| | | |
`-- "1" --^-- "." -->-------------------v-->--'
| |
`------- "0" -------'
(up to 3 times)
range-unit:
||--v----- bytes-unit ----->--||
| |
`-- other-range-unit --'
received-by:
,-----------------.
| |
||--v-- uri-host --^-- ":" -- port -->-->--||
| |
`------------ pseudonym ------------'
received-protocol:
,--------------------------.
| |
||--^-- protocol-name -- "/" -->-- protocol-version --||
rfc850-date:
||-- day-name-l -- "," -- SP -- date2 -- SP -- time-of-day -- SP -- GMT --||
second:
||-->----- DIGIT ------v--||
| |
`--(exactly once)--'
subtype:
||-- token --||
suffix-byte-range-spec:
||-- "-" -- suffix-length --||
suffix-length:
||-->-- DIGIT --v--||
| |
`-----<-----'
tchar:
||--v--- "!" --->--||
| |
>--- "#" ---^
| |
| : |
| |
>--- "'" ---^
| |
>--- "*" ---^
| |
>--- "+" ---^
| |
>--- "-" ---^
| |
>--- "." ---^
| |
>--- "^" ---^
| |
>--- "_" ---^
| |
>--- "`" ---^
| |
>--- "|" ---^
| |
>--- "~" ---^
| |
>-- DIGIT --^
| |
`-- ALPHA --'
time-of-day:
||-- hour -- ":" -- minute -- ":" -- second --||
token:
||-->-- tchar --v--||
| |
`-----<-----'
token68:
||-->--v-- ALPHA -->--v-->---------v--||
| | | | | |
| >-- DIGIT --^ | `-- "=" --'
| | | |
| >--- "+" ---^ |
| | | |
| >--- "-" ---^ |
| | | |
| >--- "." ---^ |
| | | |
| `--- "/" ---' |
| |
`--------<--------'
type:
||-- token --||
unsatisfied-range:
||-- "*/" -- complete-length --||
weak:
||-- "W/" --||
weight:
||-- OWS -- ";" -- OWS -- "q=" -- qvalue --||
year:
||-->--- DIGIT ---v--||
| |
`--(3 times)--'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment