Elli HTTP request implementation.
An elli_http process blocks in elli_tcp:accept/2 until a client connects. It then handles requests on that connection until it's closed either by the client timing out or explicitly by the user.
abstract datatype: version()
HTTP version as a tuple, i.e. {0, 9} | {1, 0} | {1, 1}.
| accept/4 | Accept on the socket until a client connects. |
| chunk_loop/1 | |
| handle_request/4 | Handle a HTTP request that will possibly come on the socket. |
| keepalive_loop/3 | Handle multiple requests on the same connection, i.e. |
| keepalive_loop/5 | |
| mk_req/10 | |
| mk_req/7 | |
| parse_path/1 | |
| send_response/4 | Generate a HTTP response and send it to the client. |
| split_args/1 | Split the URL arguments into a proplist. |
| start_link/4 |
accept(Server, ListenSocket, Options, Callback) -> ok
Server = pid()ListenSocket = elli_tcp:socket()Options = proplists:proplist()Callback = elli_handler:callback()Accept on the socket until a client connects. Handle the request, then loop if we're using keep alive or chunked transfer. If elli_tcp:accept/3 doesn't return a socket within a configurable timeout, loop to allow code upgrades of this module.
chunk_loop(Socket) -> any()
handle_request(Socket, PrevBin, Options, Callback) -> ConnToken
Socket = elli_tcp:socket()PrevBin = binary()Options = proplists:proplist()Callback = elli_handler:callback()ConnToken = {keep_alive | close, binary()}Handle a HTTP request that will possibly come on the socket. Returns the appropriate connection token and any buffer containing (parts of) the next request.
keepalive_loop(Socket, Options, Callback) -> any()
Handle multiple requests on the same connection, i.e. "keep alive".
keepalive_loop(Socket, NumRequests, Buffer, Options, Callback) -> any()
mk_req(Method, Scheme, Host, Port, PathTuple, Headers, Body, V, Socket, Callback) -> any()
mk_req(Method, PathTuple, Headers, Body, V, Socket, Callback) -> Req
Method = elli:http_method()PathTuple = {PathType::atom(), RawPath::binary()}Headers = elli:headers()Body = elli:body()V = version()Socket = elli_tcp:socket() | undefinedCallback = elli_handler:callback()Req = elli:req()parse_path(X1) -> any()
send_response(Req, Code, Headers, UserBody) -> any()
Generate a HTTP response and send it to the client.
split_args(Qs::binary()) -> [{binary(), binary() | true}]
Split the URL arguments into a proplist. Lifted from cowboy_http:x_www_form_urlencoded/2.
start_link(Server, ListenSocket, Options, Callback) -> pid()
Server = pid()ListenSocket = elli_tcp:socket()Options = proplists:proplist()Callback = elli_handler:callback()