aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/src/guide/getting_started.ezdoc2
-rw-r--r--doc/src/guide/loop_handlers.ezdoc6
-rw-r--r--doc/src/guide/middlewares.ezdoc4
-rw-r--r--doc/src/guide/rest_handlers.ezdoc2
-rw-r--r--doc/src/guide/ws_handlers.ezdoc9
-rw-r--r--doc/src/manual/cowboy_loop.ezdoc8
-rw-r--r--doc/src/manual/cowboy_middleware.ezdoc4
-rw-r--r--doc/src/manual/cowboy_rest.ezdoc4
-rw-r--r--doc/src/manual/cowboy_sub_protocol.ezdoc3
-rw-r--r--doc/src/manual/cowboy_websocket.ezdoc28
-rw-r--r--doc/src/specs/index.ezdoc7
-rw-r--r--doc/src/specs/rfc6585.ezdoc44
-rw-r--r--doc/src/specs/rfc7230_server.ezdoc891
13 files changed, 971 insertions, 41 deletions
diff --git a/doc/src/guide/getting_started.ezdoc b/doc/src/guide/getting_started.ezdoc
index a959b45..deb7bf2 100644
--- a/doc/src/guide/getting_started.ezdoc
+++ b/doc/src/guide/getting_started.ezdoc
@@ -121,7 +121,7 @@ start(_Type, _Args) ->
Dispatch = cowboy_router:compile([
{'_', [{"/", hello_handler, []}]}
]),
- cowboy:start_http(my_http_listener, 100, [{port, 8080}],
+ {ok, _} = cowboy:start_http(my_http_listener, 100, [{port, 8080}],
[{env, [{dispatch, Dispatch}]}]
),
hello_erlang_sup:start_link().
diff --git a/doc/src/guide/loop_handlers.ezdoc b/doc/src/guide/loop_handlers.ezdoc
index 4be178e..47893a9 100644
--- a/doc/src/guide/loop_handlers.ezdoc
+++ b/doc/src/guide/loop_handlers.ezdoc
@@ -61,7 +61,7 @@ message otherwise.
``` erlang
info({reply, Body}, Req, State) ->
Req2 = cowboy_req:reply(200, [], Body, Req),
- {shutdown, Req2, State};
+ {stop, Req2, State};
info(_Msg, Req, State) ->
{ok, Req, State, hibernate}.
```
@@ -76,7 +76,7 @@ return a tuple indicating if more messages are to be expected.
The callback may also choose to do nothing at all and just
skip the message received.
-If a reply is sent, then the `shutdown` tuple should be returned.
+If a reply is sent, then the `stop` tuple should be returned.
This will instruct Cowboy to end the request.
Otherwise an `ok` tuple should be returned.
@@ -99,7 +99,7 @@ init(Req, _Opts) ->
{cowboy_loop, Req2, #state{}}.
info(eof, Req, State) ->
- {shutdown, Req, State};
+ {stop, Req, State};
info({chunk, Chunk}, Req, State) ->
cowboy_req:chunk(Chunk, Req),
{ok, Req, State};
diff --git a/doc/src/guide/middlewares.ezdoc b/doc/src/guide/middlewares.ezdoc
index 0c142f9..8b047d7 100644
--- a/doc/src/guide/middlewares.ezdoc
+++ b/doc/src/guide/middlewares.ezdoc
@@ -19,11 +19,11 @@ It is defined in the `cowboy_middleware` behavior.
This callback has two arguments. The first is the `Req` object.
The second is the environment.
-Middlewares can return one of four different values:
+Middlewares can return one of three different values:
* `{ok, Req, Env}` to continue the request processing
* `{suspend, Module, Function, Args}` to hibernate
-* `{halt, Req}` to stop processing and move on to the next request
+* `{stop, Req}` to stop processing and move on to the next request
Of note is that when hibernating, processing will resume on the given
MFA, discarding all previous stacktrace. Make sure you keep the `Req`
diff --git a/doc/src/guide/rest_handlers.ezdoc b/doc/src/guide/rest_handlers.ezdoc
index 71a471f..e6bb092 100644
--- a/doc/src/guide/rest_handlers.ezdoc
+++ b/doc/src/guide/rest_handlers.ezdoc
@@ -41,7 +41,7 @@ you need.
All callbacks take two arguments, the Req object and the State,
and return a three-element tuple of the form `{Value, Req, State}`.
-All callbacks can also return `{halt, Req, State}` to stop execution
+All callbacks can also return `{stop, Req, State}` to stop execution
of the request.
The following table summarizes the callbacks and their default values.
diff --git a/doc/src/guide/ws_handlers.ezdoc b/doc/src/guide/ws_handlers.ezdoc
index 9f0fcbb..a0cfc29 100644
--- a/doc/src/guide/ws_handlers.ezdoc
+++ b/doc/src/guide/ws_handlers.ezdoc
@@ -42,7 +42,7 @@ init(Req, _Opts) ->
<<"mychat2">>, Req),
{ok, Req2, #state{}};
false ->
- {shutdown, Req, undefined}
+ {stop, Req, undefined}
end
end.
```
@@ -75,7 +75,7 @@ ping or pong frame arrives from the client. Note that in the
case of ping and pong frames, no action is expected as Cowboy
automatically replies to ping frames.
-The handler can decide to send frames to the socket, shutdown
+The handler can decide to send frames to the socket, stop
or just continue without sending anything.
The following snippet echoes back any text frame received and
@@ -93,7 +93,7 @@ websocket_handle(_Frame, Req, State) ->
Cowboy will call `websocket_info/3` whenever an Erlang message
arrives.
-The handler can decide to send frames to the socket, shutdown
+The handler can decide to send frames to the socket, stop
or just continue without sending anything.
The following snippet forwards any `log` message to the socket
@@ -109,7 +109,8 @@ websocket_info(_Info, Req, State) ->
:: Sending frames to the socket
Cowboy allows sending either a single frame or a list of
-frames to the socket. Any frame can be sent: text, binary, ping,
+frames to the socket, in which case the frames are sent
+sequentially. Any frame can be sent: text, binary, ping,
pong or close frames.
The following example sends three frames using a single `reply`
diff --git a/doc/src/manual/cowboy_loop.ezdoc b/doc/src/manual/cowboy_loop.ezdoc
index 196cec6..79b96f9 100644
--- a/doc/src/manual/cowboy_loop.ezdoc
+++ b/doc/src/manual/cowboy_loop.ezdoc
@@ -29,10 +29,10 @@ The connection was closed normally before switching to the
loop sub protocol. This typically happens if an `ok` tuple is
returned from the `init/2` callback.
-: shutdown
+: stop
The handler requested to close the connection by returning
-a `shutdown` tuple.
+a `stop` tuple.
: timeout
@@ -72,7 +72,7 @@ A socket error ocurred.
: info(Info, Req, State)
-> {ok, Req, State}
| {ok, Req, State, hibernate}
- | {shutdown, Req, State}
+ | {stop, Req, State}
Types:
@@ -85,7 +85,7 @@ Handle the Erlang message received.
This function will be called every time an Erlang message
has been received. The message can be any Erlang term.
-The `shutdown` return value can be used to stop the receive loop,
+The `stop` return value can be used to stop the receive loop,
typically because a response has been sent.
The `hibernate` option will hibernate the process until
diff --git a/doc/src/manual/cowboy_middleware.ezdoc b/doc/src/manual/cowboy_middleware.ezdoc
index 2275d35..dacaf6c 100644
--- a/doc/src/manual/cowboy_middleware.ezdoc
+++ b/doc/src/manual/cowboy_middleware.ezdoc
@@ -21,7 +21,7 @@ optionally with its contents modified.
: execute(Req, Env)
-> {ok, Req, Env}
| {suspend, Module, Function, Args}
- | {halt, Req}
+ | {stop, Req}
Types:
@@ -41,7 +41,7 @@ The `suspend` return value will hibernate the process until
an Erlang message is received. Note that when resuming, any
previous stacktrace information will be gone.
-The `halt` return value stops Cowboy from doing any further
+The `stop` return value stops Cowboy from doing any further
processing of the request, even if there are middlewares
that haven't been executed yet. The connection may be left
open to receive more requests from the client.
diff --git a/doc/src/manual/cowboy_rest.ezdoc b/doc/src/manual/cowboy_rest.ezdoc
index f9e938a..eef622a 100644
--- a/doc/src/manual/cowboy_rest.ezdoc
+++ b/doc/src/manual/cowboy_rest.ezdoc
@@ -58,7 +58,7 @@ stacktrace of the process when the crash occurred.
:: Callbacks
-: Callback(Req, State) -> {Value, Req, State} | {halt, Req, State}
+: Callback(Req, State) -> {Value, Req, State} | {stop, Req, State}
Types:
@@ -72,7 +72,7 @@ on the `Value` type, the default value if the callback is
not defined, and more general information on when the
callback is called and what its intended use is.
-The `halt` tuple can be returned to stop REST processing.
+The `stop` tuple can be returned to stop REST processing.
It is up to the resource code to send a reply before that,
otherwise a `204 No Content` will be sent.
diff --git a/doc/src/manual/cowboy_sub_protocol.ezdoc b/doc/src/manual/cowboy_sub_protocol.ezdoc
index 4ad25f3..ee57beb 100644
--- a/doc/src/manual/cowboy_sub_protocol.ezdoc
+++ b/doc/src/manual/cowboy_sub_protocol.ezdoc
@@ -8,8 +8,7 @@ by modules that implement a protocol on top of HTTP.
: upgrade(Req, Env, Handler, Opts)
-> {ok, Req, Env}
| {suspend, Module, Function, Args}
- | {halt, Req}
- | {error, StatusCode, Req}
+ | {stop, Req}
Types:
diff --git a/doc/src/manual/cowboy_websocket.ezdoc b/doc/src/manual/cowboy_websocket.ezdoc
index 7311662..2519dba 100644
--- a/doc/src/manual/cowboy_websocket.ezdoc
+++ b/doc/src/manual/cowboy_websocket.ezdoc
@@ -22,18 +22,6 @@ Cowboy will terminate the process right after closing the
Websocket connection. This means that there is no real need to
perform any cleanup in the optional `terminate/3` callback.
-:: Types
-
-: close_code() = 1000..4999
-
-Reason for closing the connection.
-
-: frame() = close | ping | pong
- | {text | binary | close | ping | pong, iodata()}
- | {close, close_code(), iodata()}
-
-Frames that can be sent to the client.
-
:: Meta values
: websocket_compress
@@ -69,10 +57,10 @@ further details.
The remote endpoint closed the connection with the given
`Code` and `Payload` as the reason.
-: shutdown
+: stop
The handler requested to close the connection, either by returning
-a `shutdown` tuple or by sending a `close` frame.
+a `stop` tuple or by sending a `close` frame.
: timeout
@@ -111,21 +99,21 @@ A socket error ocurred.
| {ok, Req, State, hibernate}
| {reply, OutFrame | [OutFrame], Req, State}
| {reply, OutFrame | [OutFrame], Req, State, hibernate}
- | {shutdown, Req, State}
+ | {stop, Req, State}
Types:
* InFrame = {text | binary | ping | pong, binary()}
* Req = cowboy_req:req()
* State = any()
-* OutFrame = frame()
+* OutFrame = cow_ws:frame()
Handle the data received from the Websocket connection.
This function will be called every time data is received
from the Websocket connection.
-The `shutdown` return value can be used to close the
+The `stop` return value can be used to close the
connection. A close reply will also result in the connection
being closed.
@@ -138,21 +126,21 @@ Erlang message.
| {ok, Req, State, hibernate}
| {reply, OutFrame | [OutFrame], Req, State}
| {reply, OutFrame | [OutFrame], Req, State, hibernate}
- | {shutdown, Req, State}
+ | {stop, Req, State}
Types:
* Info = any()
* Req = cowboy_req:req()
* State = any()
-* OutFrame = frame()
+* OutFrame = cow_ws:frame()
Handle the Erlang message received.
This function will be called every time an Erlang message
has been received. The message can be any Erlang term.
-The `shutdown` return value can be used to close the
+The `stop` return value can be used to close the
connection. A close reply will also result in the connection
being closed.
diff --git a/doc/src/specs/index.ezdoc b/doc/src/specs/index.ezdoc
new file mode 100644
index 0000000..847780b
--- /dev/null
+++ b/doc/src/specs/index.ezdoc
@@ -0,0 +1,7 @@
+::: Cowboy Implementation Reference
+
+The implementation reference documents the behavior of Cowboy
+with regards to various standards and specifications.
+
+* ^"RFC6585 status codes^rfc6585
+* ^"RFC7230 HTTP/1.1 server^rfc7230_server
diff --git a/doc/src/specs/rfc6585.ezdoc b/doc/src/specs/rfc6585.ezdoc
new file mode 100644
index 0000000..7b19aa0
--- /dev/null
+++ b/doc/src/specs/rfc6585.ezdoc
@@ -0,0 +1,44 @@
+::: RFC6585
+
+This document lists status codes that Cowboy implements as
+defined in the RFC6585 specifications.
+
+:: Status codes
+
+: 428 Precondition Required (RFC6585 3)
+
+The server requires the request to this resource to be conditional.
+
+The response should explain how to resubmit the request successfully.
+
+: 429 Too Many Requests (RFC6585 4, RFC6585 7.2)
+
+The user has sent too many requests in a given amount of time.
+
+The response should detail the rates allowed.
+
+The retry-after header can be used to indicate how long the
+user has to wait before making a new request.
+
+When an attack is detected it is recommended to drop the
+connection directly instead of sending this response.
+
+: 431 Request Header Fields Too Large (RFC6585 5, RFC6585 7.3)
+
+The request's header fields are too large.
+
+When rejecting a single header, the response should detail
+which header was at fault.
+
+When an attack is detected it is recommended to drop the
+connection directly instead of sending this response.
+
+: 511 Network Authentication Required (RFC6585 6)
+
+The user needs to authenticate into the network to gain access.
+
+This status code is meant to be used by proxies only, not by
+origin servers.
+
+The response should contain a link to the resource allowing
+the user to log in.
diff --git a/doc/src/specs/rfc7230_server.ezdoc b/doc/src/specs/rfc7230_server.ezdoc
new file mode 100644
index 0000000..9ccac94
--- /dev/null
+++ b/doc/src/specs/rfc7230_server.ezdoc
@@ -0,0 +1,891 @@
+::: RFC7230 HTTP/1.1 server
+
+This document lists the rules the Cowboy server follows based
+on the RFC7230 HTTP specifications.
+
+:: Listener
+
+The default port for "http" connections is 80. The connection
+uses plain TCP. (RFC7230 2.7.1)
+
+The default port for "https" connections is 443. The connection
+uses TLS. (RFC7230 2.7.2)
+
+Any other port may be used for either of them.
+
+:: Before the request
+
+A configurable number of empty lines (CRLF) preceding the request
+must be ignored. At least 1 empty line must be ignored. (RFC7230 3.5)
+
+When receiving a response instead of a request, identified by the
+status-line which starts with the HTTP version, the server must
+reject the message with a 501 status code and close the connection. (RFC7230 3.1)
+
+:: Request
+
+It is only necessary to parse elements required to process the
+request. (RFC7230 2.5)
+
+Parsed elements are subject to configurable limits. A server must
+be able to parse elements at least as long as it generates. (RFC7230 2.5)
+
+The request must be parsed as a sequence of octets in an encoding
+that is a superset of US-ASCII. (RFC7230 2.5)
+
+```
+HTTP-request = request-line *( header-field CRLF ) CRLF [ message-body ]
+```
+
+The general format of HTTP requests is strict. No empty line is
+allowed in-between components except for the empty line
+indicating the end of the list of headers.
+
+It is not necessary to read the message-body before processing
+the request as the message-body may be dropped depending on the
+outcome of the processing.
+
+The time the request (request line and headers) takes to be
+received by the server must be limited and subject to configuration.
+A server must wait at least 5 seconds before dropping the connection.
+A 418 status code must be sent if the request line was received
+fully when the timeout is triggered.
+
+An HTTP/1.1 server must understand any valid HTTP/1.0 request,
+and respond to those with an HTTP/1.1 message that only use
+features understood or safely ignored by HTTP/1.0 clients. (RFC7230 A)
+
+:: Request line
+
+It is recommended to limit the request-line length to a configurable
+limit of at least 8000 octets. However, as the possible line length is
+highly dependent on what form the request-target takes, it is preferrable
+to limit each individual components of the request-target. (RFC7230 3.1.1)
+
+A request line too long must be rejected with a 414 status code
+and the closing of the connection. (RFC7230 3.1.1)
+
+```
+method SP request-target SP version CRLF
+```
+
+:: Method
+
+```
+method = token ; case sensitive
+token = 1*tchar
+tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
+```
+
+The request method is defined as 1+ token characters. An invalid
+or empty method must be rejected with a 400 status code and the
+closing of the connection. (RFC7230 3.1.1, RFC7230 3.2.6)
+
+In practice the only characters in use by registered methods are
+uppercase letters [A-Z] and the dash "-". (IANA HTTP Method Registry)
+
+The length of the method must be subject to a configurable limit.
+A method too long must be rejected with a 501 status code and the
+closing of the connection. (RFC7230 3.1.1)
+
+A good default for the method length limit is the longest method
+length the server implements. (RFC7230 3.1.1)
+
+:: Between method and request-target
+
+A request that uses anything other than SP as separator between
+the method and the request-target must be rejected with a 400
+status code and the closing of the connection. (RFC7230 3.1.1, RFC7230 3.5)
+
+:: Request target
+
+There are four request-target forms. A server must be able to
+handle at least origin-form and absolute-form. The other two
+forms are specific to the CONNECT and site-wide OPTIONS method,
+respectively. (RFC7230 5.3.2)
+
+The fragment part of the target URI is not sent. It must be
+ignrored by a server receiving it. (RFC7230 5.1)
+
+```
+request-target = origin-form / absolute-form / authority-form / asterisk-form
+```
+
+Any other form is invalid and must be rejected with a 400
+status code and the closing of the connection.
+
+: origin-form
+
+origin-form is used when the client does not connect to a proxy,
+does not use the CONNECT method and does not issue a site-wide
+OPTIONS request. (RFC7230 5.3.1)
+
+```
+origin-form = absolute-path [ "?" query ]
+absolute-path = 1*( "/" segment )
+segment = *pchar
+query = *( pchar / "/" / "?" )
+
+pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
+unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
+pct-encoded = "%" HEXDIG HEXDIG
+sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
+```
+
+The scheme is either resolved from configuration or is "https"
+when on a TLS connection and "http" otherwise. (RFC7230 5.5)
+
+The authority is sent in the host header. (RFC7230 5.3.1, RFC7230 5.5)
+
+The absolute-path always starts with "/" and ends with either "?", "#"
+or the end of the URI. (RFC3986 3.3)
+
+The query starts with "?" and ends with "#" or the end of the URI. (RFC3986 3.4)
+
+The path and query must be subject to a configurable limit.
+This limit must be at least as high as what the server generates.
+A good default would be 8000 characters. (RFC7230 2.5, RFC7230 3.1.1)
+
+A request with a too long origin-form must be rejected with
+a 414 status code and the closing of the connection. (RFC7230 3.1.1)
+
+: absolute-form
+
+absolute-form is used when the client connects to a proxy, though
+its usage is also allowed when connecting to the server directly. (RFC7230 5.3.2)
+
+In practice the scheme will be "http" or "https".
+
+The "http" and "https" schemes based URI take the following form. (RFC7230 2.7.1, RFC7230 2.7.2)
+
+```
+http-URI = "http:" "//" authority path-abempty [ "?" query ] [ "#" fragment ]
+https-URI = "https:" "//" authority path-abempty [ "?" query ] [ "#" fragment ]
+```
+
+The target URI excludes the fragment component. (RFC7230 5.1)
+
+This means that the absolute-form uses a subset of absolute-URI.
+
+```
+absolute-form = ( "http" / "https" ) "://" authority path-abempty [ "?" query ]
+authority = host [ ":" port ]
+path-abempty = *( "/" segment )
+query = *( pchar / "/" / "?" )
+
+host = IP-literal / IPv4address / reg-name
+port = *DIGIT
+
+IP-literal = "[" ( IPv6address / IPvFuture ) "]"
+
+IPv6address = 6( h16 ":" ) ls32
+ / "::" 5( h16 ":" ) ls32
+ / [ h16 ] "::" 4( h16 ":" ) ls32
+ / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
+ / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
+ / [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32
+ / [ *4( h16 ":" ) h16 ] "::" ls32
+ / [ *5( h16 ":" ) h16 ] "::" h16
+ / [ *6( h16 ":" ) h16 ] "::"
+
+ls32 = ( h16 ":" h16 ) / IPv4address ; least-significant 32 bits of address
+h16 = 1*4HEXDIG ; 16 bits of address represented in hexadecimal
+
+IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
+
+dec-octet = DIGIT / %x31-39 DIGIT / "1" 2DIGIT / "2" %x30-34 DIGIT / "25" %x30-35
+
+IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
+
+reg-name = *( unreserved / pct-encoded / sub-delims )
+
+segment = *pchar
+segment-nz = 1*pchar
+
+pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
+unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
+pct-encoded = "%" HEXDIG HEXDIG
+sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
+```
+
+The scheme and host are case insensitive and normally provided in lowercase.
+All other components are case sensitive. (RFC7230 2.7.3)
+
+Unknown schemes must be rejected with a 400 status code and the
+closing of the connection. Because only a fixed number of schemes
+are allowed, it is not necessary to limit its length.
+
+The scheme provided with the request must be dropped. The effective
+scheme is either resolved from configuration or is "https" when on
+a TLS connection and "http" otherwise. (RFC7230 5.5)
+
+An authority component with a userinfo component (and its
+"@" delimiter) is invalid. The request must be rejected with
+a 400 status code and the closing of the connection. (RFC7230 2.7.1)
+
+A URI with a missing host identifier is invalid. The request must
+be rejected with a 400 status code and the closing of the connection. (RFC7230 2.7.1)
+
+The maximum length for an IPv4address is 15 characters. No
+configurable limit is necessary.
+
+The maximum length for an IPv6address is 47 characters. No
+configurable limit is necessary.
+
+The maximum length for the reg-name component must be subject
+to a configurable limit. A good default is 255 characters. (RFC3986 3.2.2, RFC1034 3.1)
+
+It is not possible to distinguish between an IPv4address and
+a reg-name before reaching the end of the string, therefore
+the length limit for IPv4address must be ignored until that
+point.
+
+The maximum length for the port component is 5. No configurable
+limit is necessary.
+
+The authority is sent both in the URI and in the host header.
+The authority from the URI must be dropped, and the host header
+must be used instead. (RFC7230 5.5)
+
+The path always starts with "/" and ends with either "?", "#"
+or the end of the URI. (RFC3986 3.3)
+
+An empty path component is equivalent to "/". (RFC7230 2.7.3)
+
+The query starts with "?" and ends with "#" or the end of the URI. (RFC3986 3.4)
+
+The path and query must be subject to a configurable limit.
+This limit must be at least as high as what the server generates.
+A good default would be 8000 characters. (RFC7230 2.5, RFC7230 3.1.1)
+
+A request with a too long component of absolute-form must be rejected with
+a 414 status code and the closing of the connection. (RFC7230 3.1.1)
+
+: authority-form
+
+When the method is CONNECT, authority-form must be used. This
+form does not apply to any other methods which must reject the
+request with a 400 status code and the closing of the connection. (RFC7230 5.3.3)
+
+```
+authority-form = authority
+authority = host [ ":" port ]
+host = IP-literal / IPv4address / reg-name
+port = *DIGIT
+
+IP-literal = "[" ( IPv6address / IPvFuture ) "]"
+
+IPv6address = 6( h16 ":" ) ls32
+ / "::" 5( h16 ":" ) ls32
+ / [ h16 ] "::" 4( h16 ":" ) ls32
+ / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
+ / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
+ / [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32
+ / [ *4( h16 ":" ) h16 ] "::" ls32
+ / [ *5( h16 ":" ) h16 ] "::" h16
+ / [ *6( h16 ":" ) h16 ] "::"
+
+ls32 = ( h16 ":" h16 ) / IPv4address ; least-significant 32 bits of address
+h16 = 1*4HEXDIG ; 16 bits of address represented in hexadecimal
+
+IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
+
+dec-octet = DIGIT / %x31-39 DIGIT / "1" 2DIGIT / "2" %x30-34 DIGIT / "25" %x30-35
+
+IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
+
+reg-name = *( unreserved / pct-encoded / sub-delims )
+
+unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
+pct-encoded = "%" HEXDIG HEXDIG
+sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
+```
+
+An authority component with a userinfo component (and its
+"@" delimiter) is invalid. The request must be rejected with
+a 400 status code and the closing of the connection. (RFC7230 2.7.1)
+
+The maximum length for an IPv4address is 15 characters. No
+configurable limit is necessary.
+
+The maximum length for an IPv6address is 47 characters. No
+configurable limit is necessary.
+
+The maximum length for the reg-name component must be subject
+to a configurable limit. A good default is 255 characters. (RFC3986 3.2.2, RFC1034 3.1)
+
+It is not possible to distinguish between an IPv4address and
+a reg-name before reaching the end of the string, therefore
+the length limit for IPv4address must be ignored until that
+point.
+
+The maximum length for the port component is 5. No configurable
+limit is necessary.
+
+A request with a too long component of authority-form must be rejected with
+a 414 status code and the closing of the connection. (RFC7230 3.1.1)
+
+The authority is either resolved from configuration or is taken
+directly from authority-form. (RFC7230 5.5)
+
+The path and query are empty when using authority-form. (RFC7230 5.5)
+
+: asterisk-form
+
+asterisk-form is used for server-wide OPTIONS requests.
+It is invalid with any other methods which must reject the
+request with a 400 status code and the closing of the connection. (RFC7230 5.3.4)
+
+```
+asterisk-form = "*"
+```
+
+The asterisk-form always has a length of 1. No configurable limit
+is necessary.
+
+The authority is empty when using asterisk-form.
+
+The path and query are empty when using asterisk-form. (RFC7230 5.5)
+
+:: Between request-target and version
+
+A request that uses anything other than SP as separator between
+the request-target and the version must be rejected with a 400
+status code and the closing of the connection. (RFC7230 3.1.1, RFC7230 3.5)
+
+:: Request version
+
+```
+version = "HTTP/1.0" / "HTTP/1.1"
+```
+
+Any version number other than HTTP/1.0 or HTTP/1.1 must be
+rejected by a server or intermediary with a 505 status code. (RFC7230 2.6, RFC7230 A.2)
+
+A request that has whitespace different than CRLF following the
+version must be rejected with a 400 status code and the closing
+of the connection. (RFC7230 3.1.1)
+
+A request that has any whitespace or characters different than
+CRLF following the version must be rejected with a 400 status
+code and the closing of the connection. (RFC7230 3.1.1)
+
+:: Request headers
+
+```
+headers = *( header-field CRLF ) CRLF
+header-field = field-name ":" OWS field-value OWS
+
+field-name = token
+field-value = *( SP / HTAB / %21-7E / %80-FF )
+
+OWS = *( SP / HTAB )
+```
+
+The header field name is case insensitive. (RFC7230 3.2)
+
+HTTP/2 requires header field names to be lowercase. It is
+perfectly acceptable for a server supporting both to convert
+HTTP/1.1 header names to lowercase when they are received. (draft-ietf-httpbis-http2-15 8.1.2.1)
+
+Messages that contain whitespace before the header name must
+be rejected with a 400 status code and the closing of the
+connection. (RFC7230 3.2.4)
+
+Messages that contain whitespace between the header name and
+colon must be rejected with a 400 status code and the closing
+of the connection. (RFC7230 3.2.4)
+
+The header name must be subject to a configurable limit. A
+good default is 50 characters, well above the longest registered
+header. Such a request must be rejected with a 431 status code
+and the closing of the connection. (RFC7230 3.2.5, RFC6585 5, IANA Message Headers registry)
+
+The header value and the optional whitespace around it must be
+subject to a configurable limit. There is no recommendations
+for the default. 4096 characters is known to work well. Such
+a request must be rejected with a 431 status code and the closing
+of the connection. (RFC7230 3.2.5, RFC6585 5)
+
+Optional whitespace before and after the header value is not
+part of the value and must be dropped.
+
+The order of header fields with differing names is not significant. (RFC7230 3.2.2)
+
+The normal procedure for parsing headers is to read each header
+field into a hash table by field name until the empty line. (RFC7230 3)
+
+Requests with duplicate content-length or host headers must be rejected
+with a 400 status code and the closing of the connection. (RFC7230 3.3.2)
+
+Other duplicate header fields must be combined by inserting a comma
+between the values in the order they were received. (RFC7230 3.2.2)
+
+Duplicate header field names are only allowed when their value is
+a comma-separated list. In practice there is no need to perform
+a check while reading the headers as the value will become invalid
+and the error can be handled while parsing the header later on. (RFC7230 3.2.2)
+
+The request must not be processed until all headers have arrived. (RFC7230 3.2.2)
+
+The number of headers allowed in a request must be subject to
+a configurable limit. There is no recommendations for the default.
+100 headers is known to work well. Such a request must be rejected
+with a 431 status code and the closing of the connection. (RFC7230 3.2.5, RFC6585 5)
+
+When parsing header field values, the server must ignore empty
+list elements, and not count those as the count of elements present. (RFC7230 7)
+
+The information in the via header is largely unreliable. (RFC7230 5.7.1)
+
+:: Request body
+
+```
+message-body = *OCTET
+```
+
+The message body is the octets after decoding any transfer
+codings. (RFC7230 3.3)
+
+A request has a message body only if it includes a transfer-encoding
+header or a non-zero content-length header. (RFC7230 3.3)
+
+```
+Transfer-Encoding = 1#transfer-coding
+
+transfer-coding = "chunked" / "compress" / "deflate" / "gzip" / transfer-extension
+transfer-extension = token *( OWS ";" OWS transfer-parameter )
+transfer-parameter = token BWS "=" BWS ( token / quoted-string )
+```
+
+The transfer-coding is case insensitive. (RFC7230 4)
+
+There are no known other transfer-extension with the exception of
+deprecated aliases "x-compress" and "x-gzip". (IANA HTTP Transfer Coding Registry,
+RFC7230 4.2.1, RFC7230 4.2.3, RFC7230 8.4.2)
+
+A server must be able to handle at least chunked transfer-encoding.
+This is also the only coding that sees widespread use. (RFC7230 3.3.1, RFC7230 4.1)
+
+Messages encoded more than once with chunked transfer-encoding
+must be rejected with a 400 status code and the closing of the
+connection. (RFC7230 3.3.1)
+
+Messages where chunked, when present, is not the last
+transfer-encoding must be rejected with a 400 status code
+and the closing of the connection. (RFC7230 3.3.3)
+
+Some non-conformant implementations send the "deflate" compressed
+data without the zlib wrapper. (RFC7230 4.2.2)
+
+Messages encoded with a transfer-encoding the server does not
+understand must be rejected with a 501 status code and the
+closing of the connection. (RFC7230 3.3.1)
+
+A server can reject requests with a body and no content-length
+header with a 411 status code. (RFC7230 3.3.3)
+
+```
+Content-Length = 1*DIGIT
+```
+
+A request with an invalid content-length header must be rejected
+with a 400 status code and the closing of the connection. (RFC7230 3.3.3)
+
+The content-length header ranges from 0 to infinity. Requests
+with a message body too large must be rejected with a 413 status
+code and the closing of the connection. (RFC7230 3.3.2)
+
+When a message includes both transfer-encoding and content-length
+headers, the content-length header must be removed before processing
+the request. (RFC7230 3.3.3)
+
+If a socket error occurs while reading the body the server
+must send a 400 status code response and close the connection. (RFC7230 3.3.3, RFC7230 3.4)
+
+If a timeout occurs while reading the body the server must
+send a 408 status code response and close the connection. (RFC7230 3.3.3, RFC7230 3.4)
+
+: Body length
+
+The length of a message with a transfer-encoding header can
+only be determined on decoding completion. (RFC7230 3.3.3)
+
+The length of a message with a content-length header is
+the numeric value in octets found in the header. (RFC7230 3.3.3)
+
+A message with no transfer-encoding or content-length header
+has a body length of 0. (RFC7230 3.3.3)
+
+: Chunked transfer-encoding
+
+```
+chunked-body = *chunk last-chunk trailer-part CRLF
+
+chunk = chunk-size [ chunk-ext ] CRLF chunk-data CRLF
+chunk-size = 1*HEXDIG
+chunk-data = 1*OCTET ; a sequence of chunk-size octets
+
+last-chunk = 1*("0") [ chunk-ext ] CRLF
+```
+
+The chunk-size field is a string of hex digits indicating the size of
+the chunk-data in octets.
+
+```
+chunk-ext = *( ";" chunk-ext-name [ "=" chunk-ext-val ] )
+chunk-ext-name = token
+chunk-ext-val = token / quoted-string
+```
+
+Unknown chunk extensions must be ignored. (RFC7230 4.1.1)
+
+The chunk-size line length must be subject to configuration.
+There are no recommended defaults, although 100 octets should work.
+Requests with a too long line must be rejected with a 400 status
+code and the closing of the connection.
+
+```
+trailer-part = *( header-field CRLF )
+```
+
+Trailing headers must not include transfer-encoding, content-length,
+host, cache-control, expect, max-forwards, pragma, range, te,
+if-match, if-none-match, if-modified-since, if-unmodified-since,
+if-range, www-authenticate, authorization, proxy-authenticate,
+proxy-authorization, age, cache-control, expires, date, location,
+retry-after, vary, warning, content-encoding, content-type,
+content-range, or trailer. (RFC7230 4.1.2)
+
+Trailer headers can be ignored safely. (RFC7230 4.1.2)
+
+When trailer headers are processed, invalid headers must be ignored.
+Valid headers must be added to the list of headers of the request. (RFC7230 4.1.2)
+
+The number of trailer headers must be subject to configuration.
+There is no known recommendations for the default. A value of 10
+should cover most cases. Requests with too many trailer headers
+must be rejected with a 431 status code and the closing of the
+connection. (RFC6585 5)
+
+Upon completion of chunk decoding the server must add a content-length
+header with the value set to the total length of data read. (RFC7230 4.1.3)
+
+Upon completion of chunk decoding the server must remove "chunked"
+from the transfer-encoding header. This header must be removed if
+it becomes empty following this removal. (RFC7230 4.1.3)
+
+Upon completion of chunk decoding the server must remove the trailer
+header from the list of headers. (RFC7230 4.1.3)
+
+```
+Trailer = 1#field-name
+```
+
+The trailer header can be used to list the headers found in the
+trailer. A server must have the option of ignoring trailer headers
+that were not listed in the trailer header. (RFC7230 4.4)
+
+The trailer header must be listed in the connection header field.
+Trailers must be ignored otherwise.
+
+:: Connection management
+
+Never assume any two requests on a single connection come
+from the same user agent. (RFC7230 2.3)
+
+```
+Connection = 1#token ; case-insensitive
+```
+
+The connection token is either case insensitive "close", "keep-alive"
+or a header field name.
+
+There are no corresponding "close" or "keep-alive" headers. (RFC7230 8.1, RFC7230 A.2)
+
+The connection header is valid only for the immediate connection,
+alongside any header field it lists. (RFC7230 6.1)
+
+The server must determine if the connection is persistent for
+every message received by looking at the connection header and
+HTTP version. (RFC7230 6.3)
+
+HTTP/1.1 requests with no "close" option and HTTP/1.0 with the
+"keep-alive" option indicate the connection will persist. (RFC7230 6.1, RFC7230 6.3)
+
+HTTP/1.1 requests with the "close" option and HTTP/1.0 with no
+"keep-alive" option indicate the connection will be closed
+upon reception of the response by the client. (RFC7230 6.1, RFC7230 6.3)
+
+The maximum number of requests sent using a persistent connection
+must be subject to configuration. The connection must be closed
+when the limit is reached. (RFC7230 6.3)
+
+A server that doesn't want to read the entire body of a message
+must close the connection, if possible after sending the "close"
+connection option in the response. (RFC7230 6.3)
+
+A server can receive more than one request before any response
+is sent. This is called pipelining. The requests can be processed
+in parallel if they all have safe methods. Responses must be sent
+in the same order as the requests. (RFC7230 6.3.2)
+
+The server must reject abusive traffic by closing the connection.
+Abusive traffic can come from the form of too many requests in a
+given amount of time, or too many concurrent connections. Limits
+must be subject to configuration. (RFC7230 6.4)
+
+The server must close inactive connections. The timeout
+must be subject to configuration. (RFC7230 6.5)
+
+The server must monitor connections for the close signal
+and close the socket on its end accordingly. (RFC7230 6.5)
+
+A connection close may occur at any time. (RFC7230 6.5)
+
+The server must not process any request after sending or
+receiving the "close" connection option. (RFC7230 6.6)
+
+The server must close the connection in stages to avoid the
+TCP reset problem. The server starts by closing the write
+side of the socket. The server then reads until it detects
+the socket has been closed, until it can be certain its
+last response has been received by the client, or until
+a close or timeout occurs. The server then fully close the
+connection. (6.6)
+
+:: Routing
+
+```
+Host = authority ; same as authority-form
+```
+
+An HTTP/1.1 request that lack a host header must be rejected with
+a 400 status code and the closing of the connection. (RFC7230 5.4)
+
+An HTTP/1.0 request that lack a host header is valid. Behavior
+for these requests is configuration dependent. (RFC7230 5.5)
+
+A request with an invalid host header must be rejected with a
+400 status code and the closing of the connection. (RFC7230 5.4)
+
+An authority component with a userinfo component (and its
+"@" delimiter) is invalid. The request must be rejected with
+a 400 status code and the closing of the connection. (RFC7230 2.7.1)
+
+When using absolute-form the URI authority component must be
+identical to the host header. Invalid requests must be rejected
+with a 400 status code and the closing of the connection. (RFC7230 5.4)
+
+When using authority-form the URI authority component must be
+identical to the host header. Invalid requests must be rejected
+with a 400 status code and the closing of the connection.
+
+The host header is empty when the authority component is undefined. (RFC7230 5.4)
+
+The effective request URI can be rebuilt by concatenating scheme,
+"://", authority, path and query components. (RFC7230 5.5)
+
+Resources with identical URI except for the scheme component
+must be treated as different. (RFC7230 2.7.2)
+
+:: Response
+
+A server can send more than one response per request only when a
+1xx response is sent preceding the final response. (RFC7230 5.6)
+
+A server that does parallel pipelining must send responses in the
+same order as the requests came in. (RFC7230 5.6)
+
+```
+HTTP-response = status-line *( header-field CRLF ) CRLF [ message-body ]
+```
+
+The response format must be followed strictly.
+
+```
+status-line = HTTP-version SP status-code SP reason-phrase CRLF
+status-code = 3DIGIT
+reason-phrase = *( HTAB / SP / VCHAR / obs-text )
+```
+
+A server must send its own version. (RFC7230 2.6)
+
+An HTTP/1.1 server may send an HTTP/1.0 version for compatibility purposes. (RFC7230 2.6)
+
+RFC6585 defines additional status code a server can use to reject
+messages. (RFC7230 9.3, RFC6585)
+
+:: Response headers
+
+In responses, OWS must be generated as SP or not generated
+at all. RWS must be generated as SP. BWS must not be
+generated. (RFC7230 3.2.3)
+
+```
+header-field = field-name ":" SP field-value
+
+field-name = token ; case-insensitive
+field-value = *( SP / %21-7E / %80-FF )
+```
+
+In quoted-string found in field-value, quoted-pair must only be
+used for DQUOTE and backslash. (RFC7230 3.2.6)
+
+The server must not generate comments in header values.
+
+HTTP header values must use US-ASCII encoding and must only send
+printable characters or SP. (RFC7230 3.2.4, RFC7230 9.4)
+
+The server must not generate empty list elements in headers. (RFC7230 7)
+
+When encoding an URI as part of a response, only characters that
+are reserved need to be percent-encoded. (RFC7230 2.7.3)
+
+The set-cookie header must be handled as a special case. There
+must be exactly one set-cookie header field per cookie. (RFC7230 3.2.2)
+
+The server must list headers for or about the immediate connection
+in the connection header field. (RFC7230 6.1)
+
+A server that does not support persistent connections must
+send "close" in every non-1xx response. (RFC7230 6.1)
+
+A server must not send a "close" connection option
+in 1xx responses. (RFC7230 6.1)
+
+The "close" connection must be sent in a message when the
+sender knows it will close the connection after fully sending
+the response. (RFC7230 6.6)
+
+A server must close the connection after sending or
+receiving a "close" once the response has been sent. (RFC7230 6.6)
+
+A server must send a "close" in a response to a request
+containing a "close". (RFC7230 6.6)
+
+:: Response body
+
+Responses to HEAD requests never include a message body. (RFC7230 3.3)
+
+2xx responses to CONNECT requests never include a message
+body. (RFC7230 3.3)
+
+1xx, 204 and 304 responses never include a message body. (RFC7230 3.3)
+
+Responses to HEAD requests and 304 responses can include a
+content-length or transfer-encoding header. Their value must
+be the same as if the request was an unconditional GET. (RFC7230 3.3, RFC7230 3.3.1, RFC7230 3.3.2)
+
+1xx, 204 responses and 2xx responses to CONNECT requests must
+not include a content-length or transfer-encoding header. (RFC7230 3.3.1, RFC7230 3.3.2)
+
+```
+message-body = *OCTET
+```
+
+The message body is the octets after decoding any transfer
+codings. (RFC7230 3.3)
+
+When the length is known in advance, the server must send a
+content-length header, including if the length is 0. (RFC7230 3.3.2, RFC7230 3.3.3)
+
+When the length is not known in advance, the chunked transfer-encoding
+must be used. (RFC7230 3.3.2, RFC7230 3.3.3)
+
+For compatibility purposes a server can send no content-length or
+transfer-encoding header. In this case the connection must be
+closed after the response has been sent fully. (RFC7230 3.3.2, RFC7230 3.3.3)
+
+The content-length header must not be sent when a transfer-encoding
+header already exists. (RFC7230 3.3.2)
+
+The server must not apply the chunked transfer-encoding more than
+once. (RFC7230 3.3.1)
+
+The server must apply the chunked transfer-encoding last. (RFC7230 3.3.1)
+
+The transfer-encoding header must not be sent in responses to
+HTTP/1.0 requests, or in responses that use the HTTP/1.0 version.
+No transfer codings must be applied in these cases. (RFC7230 3.3.1)
+
+```
+TE = #t-codings
+
+t-codings = "trailers" / ( transfer-coding [ t-ranking ] )
+t-ranking = OWS ";" OWS "q=" rank
+rank = ( "0" [ "." 0*3DIGIT ] ) / ( "1" [ "." 0*3("0") ] )
+```
+
+Trailers can only be sent if the request includes a TE header
+containing "trailers". (RFC7230 4.1.2)
+
+The presence of "chunked" in a TE header must be ignored as it
+is always acceptable with HTTP/1.1. (RFC7230 4.3)
+
+A qvalue of 0 in the TE header means "not acceptable". (RFC7230 4.3)
+
+The lack of a TE header or an empty TE header means only "chunked"
+(with no trailers) or no transfer-encoding is acceptable. (RFC7230 4.3)
+
+The TE header must be listed in the connection header field,
+or must be ignored otherwise.
+
+Trailer headers must be listed in the trailer header field value. (RFC7230 4.4)
+
+When defined, the trailer header must also be listed in the connection header. (RFC7230 4.4)
+
+:: Upgrade
+
+```
+Upgrade = 1#protocol
+
+protocol = protocol-name ["/" protocol-version]
+protocol-name = token
+protocol-version = token
+```
+
+The upgrade header contains the list of protocols the
+client wishes to upgrade to, in order of preference. (RFC7230 6.7)
+
+The upgrade header can be safely ignored. (RFC7230 6.7)
+
+The upgrade header must be listed under the connection header,
+or must be ignored otherwise. (RFC7230 6.7)
+
+A server accepting an upgrade request must send a 101 status
+code with a upgrade header listing the protocol(s) it upgrades
+to, in layer-ascending order. In addition the upgrade header
+must be listed in the connection header. (RFC7230 6.7)
+
+A server must not switch to a protocol not listed in the
+request's upgrade header. (RFC7230 6.7)
+
+A server that sends a 426 status code must include a upgrade
+header listing acceptable protocols in order of preference. (RFC7230 6.7)
+
+A server can send a upgrade header to any response to advertise
+its support for other protocols listed in order of preference. (RFC7230 6.7)
+
+Immediately after a server responds with a 101 status code
+it must respond to the original request using the new protocol. (RFC7230 6.7)
+
+A server must not switch protocols unless the original message's
+semantics can be honored by the new protocol. OPTIONS requests
+can be honored by any protocol. (RFC7230 6.7)
+
+A server must ignore an upgrade header received by an HTTP/1.0
+request. (RFC7230 6.7)
+
+A server receiving both an upgrade header and an expect header
+containing "100-continue" must send a 100 response before the
+101 response. (RFC7230 6.7)
+
+The upgrade header field cannot be used for switching the
+connection protocol (e.g. TCP) or switching connections. (RFC7230 6.7)
+
+:: Compatibility
+
+A server can choose to be non-conformant to the specifications
+for the sake of compatibility. Such behavior can be enabled
+through configuration and/or software identification. (RFC7230 2.5)