connection.h (692B)
1 /* See LICENSE file for copyright and license details. */ 2 #ifndef CONNECTION_H 3 #define CONNECTION_H 4 5 #include "http.h" 6 #include "server.h" 7 #include "util.h" 8 9 enum connection_state { 10 C_VACANT, 11 C_RECV_HEADER, 12 C_SEND_HEADER, 13 C_SEND_BODY, 14 NUM_CONN_STATES, 15 }; 16 17 struct connection { 18 enum connection_state state; 19 int fd; 20 struct sockaddr_storage ia; 21 struct request req; 22 struct response res; 23 struct buffer buf; 24 size_t progress; 25 }; 26 27 struct connection *connection_accept(int, struct connection *, size_t); 28 void connection_log(const struct connection *); 29 void connection_reset(struct connection *); 30 void connection_serve(struct connection *, const struct server *); 31 32 #endif /* CONNECTION_H */