-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.h
53 lines (44 loc) · 1.2 KB
/
server.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef SLOWS_H
#define SLOWS_H
#include "request.h"
#include "response.h"
#include <ctime>
#include <fcntl.h>
#include <fstream>
#include <iostream>
#include <netinet/in.h>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <thread>
#include <vector>
#define METHOD_CHAR_CAP 128
#define URI_CHAR_CAP 8192
#define PROTOCOL_CHAR_CAP 128
#define LEFT_HEADER_CHAR_CAP 8192
#define RIGHT_HEADER_CHAR_CAP 8192
class SLOWS {
private:
unsigned short int Port;
int SocketFD;
std::string HomeDir = "/var/www/.SLOWS";
std::string IndexFile = "index.html";
std::vector<std::string> AllowedMethods;
bool Logging = true;
public:
SLOWS();
void Listen(const unsigned short port = 8080);
void Static(std::string path = "~/.SLOWS");
void Prepare(int clientSocket);
void BreakConnection(int clientSocket, short status);
void MethodeController(int clientSocket, SLOWSReq *req);
void MethodeGet(int clientSocket, SLOWSReq *req, SLOWSRes *res);
void MethodeHead(int clientSocket, SLOWSReq *req, SLOWSRes *res);
void Logger(std::string msg);
virtual ~SLOWS();
};
#endif