merge master
This commit is contained in:
@@ -2,12 +2,14 @@
|
||||
#ifndef WEBSERV_HPP
|
||||
# define WEBSERV_HPP
|
||||
|
||||
# include <string>
|
||||
# include <map>
|
||||
# include <cerrno> // errno
|
||||
# include <cstdio> // perror
|
||||
# include <vector>
|
||||
# include <exception>
|
||||
# include <stdexcept>
|
||||
# include <string>
|
||||
# include <sstream> // stringstream
|
||||
# include <cerrno> // errno
|
||||
# include <cstdio> // perror
|
||||
# include <unistd.h> // close
|
||||
# include <iostream> // cout, cin
|
||||
# include <cstring> // memset
|
||||
@@ -17,13 +19,15 @@
|
||||
# include <sys/epoll.h> // epoll
|
||||
# include <fcntl.h> // fcntl
|
||||
# include <sys/wait.h> // waitpid
|
||||
# include <sstream> // stringstream
|
||||
# include <csignal> // signal
|
||||
|
||||
#define BUFSIZE 8192
|
||||
#define TIMEOUT 10 * 1000
|
||||
#define MAX_EVENTS 42 // arbitrary
|
||||
#define MSG_TEST "Le Webserv / 20 =D\n"
|
||||
#define MSG_BOUNCE "bounced properly ;)\n" // placeholder
|
||||
# include "Client.hpp"
|
||||
# include "Server.hpp"
|
||||
|
||||
# define BUFSIZE 8192
|
||||
# define TIMEOUT 10 * 1000
|
||||
# define MAX_EVENTS 42 // arbitrary
|
||||
# define MSG_TEST "Le Webserv / 20 =D\n"
|
||||
|
||||
class Webserv
|
||||
{
|
||||
@@ -37,20 +41,26 @@ class Webserv
|
||||
void start();
|
||||
|
||||
private:
|
||||
int _socket_fd; // TODO: replace with vector of "Server" struct
|
||||
int _epfd;
|
||||
int _socket_fd; // temp, to replace with std::vector<Server>
|
||||
// std::vector<Server> _servers;
|
||||
std::vector<Client> _clients;
|
||||
|
||||
// WIP global buffer. Need one variable set per "Client"
|
||||
char _buf[BUFSIZE+1];
|
||||
ssize_t _read_ret;
|
||||
std::map<std::string, std::string> _request;
|
||||
std::map<std::string, std::string> _response;
|
||||
void _accept_connection(int fd);
|
||||
void _read_request(Client *client);
|
||||
void _send_response(Client *client);
|
||||
|
||||
int _epoll_update(int fd, uint32_t events, int op);
|
||||
int _epoll_update(int fd, uint32_t events, int op, void *ptr);
|
||||
|
||||
void _handle_last_signal();
|
||||
// void _signal_handler(int signum); // invalide dans une class
|
||||
Client* _actual_client;
|
||||
void _close_client(int fd);
|
||||
void _close_all_clients();
|
||||
|
||||
void _bind(int socket_fd, in_port_t port);
|
||||
void _listen(int socket_fd, unsigned int max_connections);
|
||||
void _accept_connection(int fd);
|
||||
void _read_request(int fd);
|
||||
void _send_response(int fd);
|
||||
|
||||
// TMP HUGO TEST CGI
|
||||
void _serve_file(int fd, std::string page);
|
||||
|
||||
Reference in New Issue
Block a user