init
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
|||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
*.o
|
||||||
|
*.swp
|
||||||
|
*.out
|
||||||
|
*.exe
|
||||||
|
*.stackdump
|
||||||
|
*.a
|
||||||
|
*.so
|
||||||
|
*.dSYM
|
||||||
|
.vscode
|
||||||
|
*.lnk
|
||||||
|
*.zip
|
||||||
|
|
||||||
|
ubuntu_tester
|
||||||
|
ubuntu_cgi_tester
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
NAME = webserv
|
||||||
|
|
||||||
|
CXX = c++
|
||||||
|
|
||||||
|
CXXFLAGS = -Wall -Wextra -Werror
|
||||||
|
CXXFLAGS += -std=c++98
|
||||||
|
CXXFLAGS += -I$(HEADERS_D)
|
||||||
|
#CXXFLAGS += -g
|
||||||
|
#CXXFLAGS += -O3
|
||||||
|
|
||||||
|
SHELL = /bin/zsh
|
||||||
|
VPATH = $(DIR_SRCS)
|
||||||
|
DIR_SRCS = tests
|
||||||
|
|
||||||
|
HEADERS_D = ./templates
|
||||||
|
HEADERS =
|
||||||
|
|
||||||
|
DEPENDENCIES = $(HEADERS:%=$(HEADERS_D)/%)
|
||||||
|
|
||||||
|
SRCS = main.cpp
|
||||||
|
|
||||||
|
DIR_OBJS = builds
|
||||||
|
OBJS = $(SRCS:%.cpp=$(DIR_OBJS)/%.o)
|
||||||
|
|
||||||
|
# --------------------
|
||||||
|
# ------ RULES -------
|
||||||
|
# --------------------
|
||||||
|
|
||||||
|
all: $(NAME)
|
||||||
|
|
||||||
|
$(DIR_OBJS)/%.o: $(SRCS) | $(DIR_OBJS)
|
||||||
|
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(DIR_OBJS):
|
||||||
|
mkdir $@
|
||||||
|
|
||||||
|
$(OBJS): $(DEPENDENCIES)
|
||||||
|
#$(OBJS): $(DEPENDENCIES) Makefile
|
||||||
|
|
||||||
|
$(NAME) :
|
||||||
|
$(CXX) $(OBJS) -o $(NAME)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(OBJS)
|
||||||
|
|
||||||
|
fclean: clean
|
||||||
|
rm -f $(NAME)
|
||||||
|
|
||||||
|
re: fclean all
|
||||||
|
|
||||||
|
#run: all
|
||||||
|
|
||||||
|
.PHONY : all clean fclean re run
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
//# include <iostream>
|
||||||
|
# include <string>
|
||||||
|
# include <map>
|
||||||
|
# include <cerrno> // errno
|
||||||
|
# include <cstdio> // perror
|
||||||
|
|
||||||
|
|
||||||
|
// --------------------------------------------
|
||||||
|
// Verifier si les fonctions sont dispos dans des headers C++
|
||||||
|
|
||||||
|
|
||||||
|
# include <fcntl.h> // fcntl
|
||||||
|
|
||||||
|
// htonl, htons, ntohl, ntohs, inet_addr
|
||||||
|
# include <arpa/inet.h>
|
||||||
|
|
||||||
|
// socket, accept, listen, send, recv, bind, connect, setsockopt, getsockname
|
||||||
|
# include <sys/socket.h>
|
||||||
|
|
||||||
|
# include <poll.h> // poll
|
||||||
|
// OR
|
||||||
|
# include <sys/select.h> // select
|
||||||
|
// OR
|
||||||
|
# include <sys/epoll.h> // epoll
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
- un thread par serveur présent dans le fichier de config ?
|
||||||
|
|
||||||
|
----------------
|
||||||
|
|
||||||
|
----------------
|
||||||
|
Un truc cool et surtout bien utile ici c'est d'utiliser un proxy entre ton navigateur et ton serveur pour vérifier ce qui est envoyé en raw. Les navigateurs peuvent avoir des comportements différents.
|
||||||
|
Vous avez des modules sur vos navigateur ou des logiciels externe. C'est assez rapide et gratuit.
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
#include "Webserv.hpp"
|
||||||
|
|
||||||
|
Webserv::Webserv()
|
||||||
|
{
|
||||||
|
_socket_fd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
|
||||||
|
if (_socket_fd == -1)
|
||||||
|
{
|
||||||
|
perror("socket(): ");
|
||||||
|
throw std::runtime_error("Socket init");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Webserv::Webserv(Webserv const &src)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Webserv::~Webserv()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Webserv & Webserv::operator=(Webserv const &rhs)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
#ifndef WEBSERV_HPP
|
||||||
|
# define WEBSERV_HPP
|
||||||
|
|
||||||
|
# include <string>
|
||||||
|
# include <map>
|
||||||
|
# include <cerrno> // errno
|
||||||
|
# include <cstdio> // perror
|
||||||
|
# include <exception>
|
||||||
|
# include <stdexcept>
|
||||||
|
|
||||||
|
# include <sys/socket.h> // socket, accept, listen, send, recv, bind, connect, setsockopt, getsockname
|
||||||
|
|
||||||
|
class Webserv
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//Webserv(Placeholder);
|
||||||
|
Webserv();
|
||||||
|
Webserv(Webserv const &src);
|
||||||
|
~Webserv();
|
||||||
|
Webserv &operator=(Webserv const &rhs);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _socket_fd;
|
||||||
|
std::map<std::string, std::string> _request;
|
||||||
|
std::map<std::string, std::string> _response;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user