WIP CGI monitered by epoll
+ OK, but some errors case need to be lookup
This commit is contained in:
@@ -44,6 +44,15 @@ void signal_handler(int signum);
|
||||
|
||||
# define MIME_TYPE_DEFAULT "application/octet-stream"
|
||||
|
||||
struct cgi_pipe_rfd
|
||||
{
|
||||
int fd;
|
||||
pid_t cgi_pid;
|
||||
Client *client;
|
||||
};
|
||||
bool operator==(const cgi_pipe_rfd& lhs, int fd);
|
||||
bool operator==(int fd, const cgi_pipe_rfd& rhs);
|
||||
|
||||
class Webserv
|
||||
{
|
||||
public:
|
||||
@@ -65,6 +74,7 @@ class Webserv
|
||||
private:
|
||||
int _epfd;
|
||||
std::vector<listen_socket> _listen_sockets;
|
||||
std::vector<cgi_pipe_rfd> _cgi_pipe_rfds;
|
||||
std::vector<ServerConfig> _servers;
|
||||
std::vector<Client> _clients;
|
||||
std::map<int, std::string> _http_status;
|
||||
@@ -107,6 +117,8 @@ class Webserv
|
||||
void _close_client(int fd);
|
||||
void _close_all_clients();
|
||||
void _close_all_clients_fd();
|
||||
void _close_cgi_pipe_rfd(int fd);
|
||||
void _close_all_cgi_pipe_rfd();
|
||||
void _close_all_listen_sockets();
|
||||
void _reopen_lsocket(std::vector<listen_socket>::iterator it);
|
||||
void _handle_epoll_error_lsocket(uint32_t events, std::vector<listen_socket>::iterator it);
|
||||
@@ -121,18 +133,26 @@ class Webserv
|
||||
// cgi.cpp
|
||||
bool _is_cgi(Client *client, std::string path);
|
||||
size_t _cgi_pos(Client *client, std::string &path, size_t pos);
|
||||
std::string _exec_cgi(Client *client);
|
||||
void _exec_cgi(Client *client);
|
||||
void _set_env_vector(Client *client, std::vector<std::string> &env_vector);
|
||||
void _set_env_cstr(char *env_cstr[], std::vector<std::string> &env_vector);
|
||||
std::string _dup_env(std::string var, std::string val);
|
||||
std::string _dup_env(std::string var, int i);
|
||||
std::string _exec_script(Client *client, char *env[]);
|
||||
void _exec_script(Client *client, char *env[]);
|
||||
void _check_script_output(Client *client, std::string & output);
|
||||
void _check_script_status(Client *client, std::string & output);
|
||||
void _check_script_fields(Client *client, std::string & output);
|
||||
void _add_script_body_length_header(std::string & output);
|
||||
void _remove_body_leading_empty_lines(std::string & output);
|
||||
|
||||
|
||||
|
||||
void _read_cgi_output(cgi_pipe_rfd &cgi_fd);
|
||||
void _handle_epoll_error_cgi_fd(uint32_t events, std::vector<cgi_pipe_rfd>::iterator it);
|
||||
void _cgi_epollhup(uint32_t events, std::vector<cgi_pipe_rfd>::iterator it);
|
||||
|
||||
|
||||
|
||||
///////////////////////
|
||||
class ExecFail : public std::exception
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user