-
Notifications
You must be signed in to change notification settings - Fork 0
Technical details
Alexander Andreev edited this page Jun 1, 2017
·
1 revision
Charon uses single-threaded event-driven architecture. Socket I/O events is multiplexed via epoll
.
- Client is accepted.
http_connection_t
object is created by http handler. - Data arrived. Depending on current state,
http_handler_on_read_request_line
orhttp_handler_on_read_handlers
called. Those functions process HTTP header and route request according to the configuration file. - Start of request processing. At this stage read from client is disabled (using
epoll_ctl
) until current request is processed. That is done to prevent Charon from "mixing" responses. - Request processing. On this stage Charon is trying to either proxy response to upstream or handle local file.
- Local file handling. Charon forms an HTTP response using outgoing chain. Local files are sent to client using
sendfile(3)
. - Proxying the request. If request must be proxed, Charon reassembles request using information from
http_request_t
, fix some headers and form an outgoing chain to an upstream and enabled write on upstream. When request is sent, Charon enables read from upstream. Reads the response, fix headers and forms an outgoing chain for the client. - Write to client is enabled. Outgoing chain is written to the client.
-
http_end_process_request
. This is the endpoint of request processing pipeline. In this moment Charon decides, to close connection or keep it alive. If pipelined requests are pending, Charon defers a task to handle them.