+ virtual void do_work();
+
+ // Process a client; read and write data as far as we can.
+ // After this call, one of these four is true:
+ //
+ // 1. The socket is closed, and the client deleted.
+ // 2. We are still waiting for more data from the client.
+ // 3. We've sent all the data we have to the client,
+ // and put it in <sleeping_clients>.
+ // 4. The socket buffer is full (which means we still have
+ // data outstanding).
+ //
+ // For #2, we listen for EPOLLIN events. For #3 and #4, we listen
+ // for EPOLLOUT in edge-triggered mode; it will never fire for #3,
+ // but it's cheaper than taking it in and out all the time.
+ void process_client(Client *client);
+
+ // If the TLS library wants to write anything to this client,
+ // output it. Returns true if the processing should go to sleep
+ // (an error, or lack of outgoing buffer space).
+ bool send_pending_tls_data(Client *client);
+
+ // Reads regular data fro ma socket. Returns -1 if the processing
+ // should go to sleep (an error, or no data available yet), otherwise
+ // the number of bytes read.
+ int read_nontls_data(Client *client, char *buf, size_t max_size);
+
+ // Reads (decrypted) data from a TLS socket. Returns -1 if the processing
+ // should go to sleep (an error, or no data available yet), otherwise
+ // the number of bytes read. The buffer will be used as scratch space
+ // for TLS data, so it can be overwritten by more bytes than what is returned.
+ int read_tls_data(Client *client, char *buf, size_t max_size);
+
+ // Close a given client socket, and clean up after it.
+ void close_client(Client *client);
+
+ // Parse the HTTP request. Returns a HTTP status code (200/204/400/404).
+ int parse_request(Client *client);
+
+ // Construct the HTTP header, and set the client into
+ // the SENDING_HEADER state.
+ void construct_header(Client *client);
+
+ // Construct a generic error with the given line, and set the client into
+ // the SENDING_SHORT_RESPONSE state.
+ void construct_error(Client *client, int error_code);
+
+ // Construct a 204, and set the client into the SENDING_SHORT_RESPONSE state.
+ void construct_204(Client *client);
+
+ void process_queued_data();
+ void skip_lost_data(Client *client);
+
+ void add_client(int sock, Acceptor *acceptor);