elixir-lang/plug — pull request #11 by zambal (2014-02-04 10:27:35+00:00)
Title: Elli adapter

Elli works a bit differently than Cowboy and since Plug's adapter specification seems to be largely based on Cowboy, the Elli adapter needs to do some extra work to satisfy Plug's adapter expectations. A couple of things to note:

* Elli is not supervised out of the box, so the Elli adapter implements a simple supervisor.
* Except for chunked transfers, Elli only sends a response back to the client when a handler returns, so in order to allow Plug.Connection.send_resp and friends, Plug.Adapters.Elli.Handler spawns an extra process that executes the Plug handler.
* Elli doesn't support streaming of request bodies, as it always fetches the complete body before executing any handler. This means that while Plug.Adapters.Elli.Connection.stream_req_body/2 perfectly works, it doesn't do any actual streaming, but just mimics cowboy's behaviour instead.
* One can only set a max request body at startup. If a request is made with a body that exceeds this size, the request is discarded without executing any handler.
* When using a pre OTP 17.0 rc1 version, an error can occur once in a while when running mix test because of a file:sendfile/5 bug in Erlang.

TODO: Examine error reporting more closely to see if the extra process spawning in the Elli adapter changes error reporting behaviour when a Plug handler crashes