mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-28 21:07:59 +03:00
Sort
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
#ifndef AUTOINDEX_HPP
|
||||
#define AUTOINDEX_HPP
|
||||
|
||||
#include "webserv.hpp"
|
||||
|
||||
class Autoindex
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
Autoindex();
|
||||
static std::string getPage(std::string path, std::string host);
|
||||
static std::string getReference(std::string file, std::string dir, std::string host);
|
||||
~Autoindex();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,54 +0,0 @@
|
||||
#ifndef HEADER_HPP
|
||||
# define HEADER_HPP
|
||||
|
||||
#include "webserv.hpp"
|
||||
|
||||
class Header
|
||||
{
|
||||
private:
|
||||
HeaderHandl _request;
|
||||
HeaderHandl _respons;
|
||||
|
||||
private:
|
||||
int _row;
|
||||
int _ret;
|
||||
int _autoIndex;
|
||||
int _fd;
|
||||
char *_buff;
|
||||
|
||||
|
||||
std::string _fileToSend;
|
||||
std::map<std::string, std::string> _headerField;
|
||||
std::map<std::string, std::string> _errorCode;
|
||||
|
||||
public:
|
||||
std::map<std::string , std::string> getHeaderField(void);
|
||||
HeaderHandl getRequest(void);
|
||||
HeaderHandl getRespons(void);
|
||||
std::string getReasonPhrase(std::string);
|
||||
std::string getReasonPhrase(int);
|
||||
std::string getErrorPage(int code);
|
||||
void setRawData(char *);
|
||||
void setFd(int);
|
||||
int getFd(void);
|
||||
|
||||
void initErrorCode(void);
|
||||
int isFile(std::string);
|
||||
int isDir(std::string);
|
||||
void OpenResponsFile(const char *path);
|
||||
|
||||
int parseStartLine(std::string);
|
||||
void parseURI(std::string);
|
||||
int parseHeaderfield(std::string);
|
||||
void printHeaderInfo(void);
|
||||
int parseRequest(void);
|
||||
|
||||
int sendRespons(int fd);
|
||||
int sendHeader(int fd);
|
||||
void clear(void);
|
||||
Header();
|
||||
Header(char *);
|
||||
~Header();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,37 +0,0 @@
|
||||
#ifndef HEADERHANDL_HPP
|
||||
#define HEADERHANDL_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
class HeaderHandl
|
||||
{
|
||||
public:
|
||||
std::string _method;
|
||||
std::string _URI;
|
||||
std::string _fullURI;
|
||||
std::string _version;
|
||||
std::string _query;
|
||||
public:
|
||||
// std::string _allow;
|
||||
// std::string _contentLenght;
|
||||
std::string _contentType;
|
||||
std::string _host;
|
||||
// std::string _contentLanguage;
|
||||
std::string _contentLocation;
|
||||
// std::string _date;
|
||||
// std::string _lastModified;
|
||||
// std::string _transferEncoding;
|
||||
// std::string _server;
|
||||
// std::string _location;
|
||||
public:
|
||||
HeaderHandl();
|
||||
|
||||
void copyData(std::map<std::string, std::string>);
|
||||
|
||||
~HeaderHandl();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,40 +0,0 @@
|
||||
#ifndef SERVER_HPP
|
||||
#define SERVER_HPP
|
||||
|
||||
#include "webserv.hpp"
|
||||
|
||||
#define BUFFSIZE 1024
|
||||
#define MAX_CLIENT 1000
|
||||
|
||||
class Header;
|
||||
|
||||
class Server
|
||||
{
|
||||
private:
|
||||
int _port;
|
||||
int _epolfd;
|
||||
int _client;
|
||||
struct epoll_event _events[MAX_CLIENT];
|
||||
struct sockaddr_in _addres;
|
||||
std::string _ip;
|
||||
|
||||
private:
|
||||
void checkError(int fd, std::string str);
|
||||
void sendFile(std::string str);
|
||||
void sendHeader(Header head, int);
|
||||
void sendRespons(Header head, int);
|
||||
void setNonblocking(int fd);
|
||||
void newConnection(int fd);
|
||||
public:
|
||||
Server();
|
||||
Server(std::string path);
|
||||
|
||||
void readConfig(void);
|
||||
void setupConfig(void);
|
||||
void start(void);
|
||||
void end(void);
|
||||
~Server();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,59 +0,0 @@
|
||||
#ifndef SERVERCONFIG_HPP
|
||||
#define SERVERCONFIG_HPP
|
||||
|
||||
#include "webserv.hpp"
|
||||
|
||||
struct location
|
||||
{
|
||||
std::string location;
|
||||
std::string root;
|
||||
std::string directoryFile;
|
||||
std::string uploadDir;
|
||||
bool autoindex;
|
||||
bool uploadAccept;
|
||||
std::vector<std::string> methods;
|
||||
std::map<int, std::string> redirect;
|
||||
};
|
||||
|
||||
class ServerConfig
|
||||
{
|
||||
private:
|
||||
// TOMLMap *_root;
|
||||
std::string _serverName;
|
||||
std::string _host;
|
||||
int _port;
|
||||
int _clientBodySize;
|
||||
|
||||
std::map<int, std::string> _errorPages;
|
||||
std::vector<location> _locations;
|
||||
|
||||
public:
|
||||
void setServerName(std::string);
|
||||
void setHost(std::string);
|
||||
void setPort(int);
|
||||
void setClientBodySize(int);
|
||||
void setErrorPages(std::map<int, std::string>);
|
||||
void setLocations(std::vector<location>);
|
||||
// void setRoot(TOMLMap *);
|
||||
|
||||
std::string getServerName(void);
|
||||
std::string getHost(void);
|
||||
int getPort(void);
|
||||
int getClientBodySize(void);
|
||||
std::vector<location> getLocations(void);
|
||||
std::map<int, std::string> getErrorPages(void);
|
||||
// TOMLMap *getRoot(void);
|
||||
|
||||
public:
|
||||
ServerConfig();
|
||||
// ServerConfig(TOMLMap *root);
|
||||
|
||||
void fillFields(void);
|
||||
|
||||
~ServerConfig();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,33 +0,0 @@
|
||||
#ifndef SOCKET_HPP
|
||||
#define SOCKET_HPP
|
||||
|
||||
#include "webserv.hpp"
|
||||
class Socket
|
||||
{
|
||||
private:
|
||||
int _socketFd;
|
||||
socklen_t _addrlen;
|
||||
struct sockaddr_in _addres;
|
||||
|
||||
|
||||
public:
|
||||
Socket();
|
||||
Socket(int domain, int type, int protocol, int port, std::string ip);
|
||||
int getSocketFd(void);
|
||||
struct sockaddr_in getAddres(void);
|
||||
socklen_t getAddlen(void);
|
||||
struct sockaddr *getSockaddr(void);
|
||||
socklen_t *getSocklen(void);
|
||||
void setSocketFd(int);
|
||||
void setAddres(struct sockaddr_in);
|
||||
int bindingSocket(void);
|
||||
int listeningSocket(int nbr);
|
||||
int init(int nbr);
|
||||
void checkError(int fd, std::string str);
|
||||
|
||||
~Socket();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -8,53 +8,39 @@
|
||||
#define PINK "\033[35m"
|
||||
#define TURGUOISE "\033[36m"
|
||||
#define ZERO_C "\033[0m"
|
||||
|
||||
#define HOME "www"
|
||||
#define BUFFSIZE 1024
|
||||
#define MAX_CLIENT 1000
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/select.h>
|
||||
#include <poll.h>
|
||||
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/select.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <poll.h>
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <dirent.h>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
#include "Socket.hpp"
|
||||
#include "HeaderHandl.hpp"
|
||||
#include "ServerConfig.hpp"
|
||||
#include "Autoindex.hpp"
|
||||
#include "Server.hpp"
|
||||
#include "Header.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
void parse(void);
|
||||
|
||||
class toml_node;
|
||||
|
||||
/* typedef std::vector<TOMLMap *> TOMLArray; */
|
||||
/* typedef std::vector<TOMLArray *> TOMLArrayOfMap; */
|
||||
typedef std::map<std::string, toml_node *> TOMLMap; // = JSONObject
|
||||
typedef std::vector<TOMLMap *> TOMLMapArray;
|
||||
typedef std::vector<toml_node *> TOMLArray;
|
||||
|
||||
void display(TOMLMap *config);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user