Skip to content

Latest commit

 

History

History
143 lines (80 loc) · 5.6 KB

elli_http.md

File metadata and controls

143 lines (80 loc) · 5.6 KB

Module elli_http

Elli HTTP request implementation.

Description

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.

Data Types

abstract datatype: version()

HTTP version as a tuple, i.e. {0, 9} | {1, 0} | {1, 1}.

Function Index

accept/4Accept on the socket until a client connects.
chunk_loop/1
handle_request/4Handle a HTTP request that will possibly come on the socket.
keepalive_loop/3Handle multiple requests on the same connection, i.e.
keepalive_loop/5
mk_req/10
mk_req/7
parse_path/1
send_response/4Generate a HTTP response and send it to the client.
split_args/1Split the URL arguments into a proplist.
start_link/4

Function Details

accept/4


accept(Server, ListenSocket, Options, Callback) -> ok

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/1

chunk_loop(Socket) -> any()

handle_request/4


handle_request(Socket, PrevBin, Options, Callback) -> ConnToken

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/3

keepalive_loop(Socket, Options, Callback) -> any()

Handle multiple requests on the same connection, i.e. "keep alive".

keepalive_loop/5

keepalive_loop(Socket, NumRequests, Buffer, Options, Callback) -> any()

mk_req/10

mk_req(Method, Scheme, Host, Port, PathTuple, Headers, Body, V, Socket, Callback) -> any()

mk_req/7


mk_req(Method, PathTuple, Headers, Body, V, Socket, Callback) -> Req

parse_path/1

parse_path(X1) -> any()

send_response/4

send_response(Req, Code, Headers, UserBody) -> any()

Generate a HTTP response and send it to the client.

split_args/1


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/4


start_link(Server, ListenSocket, Options, Callback) -> pid()