Of course since requests are a record the response state can be explicitly
overriden, but standard use prevents errors by making sure only one reply
is sent.
* Handler:init shouldn't reply anything; send an error 500.
* Handler:handle may have sent something to the client; close the socket.
* Handler:terminate failed to clean itself up. Close the socket.
* Makes more sense to parse the host only once instead of for each path.
* Allows proper handling of: If the host is not a valid host on the server,
the response MUST be a 400 (Bad Request) error.
In the interest of robustness, servers SHOULD ignore any empty
line(s) received where a Request-Line is expected. In other words,
if the server is reading the protocol stream at the beginning of a
message and receives a CRLF first, it should ignore the CRLF.
We need an init function in order to process upgrade instructions
for protocols like WebSockets, but also to request an active receive
mode for long-polling connections, both of which will be implemented
at a later time.
Crashes can happen if we close the connection too fast, leading to
controlling_process returning {error, closed} instead of ok. This can
happen when we receive bad requests, reply with 404 Not Found and more.
Simply do not match the return value of controlling_process to avoid this.