-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp.h
48 lines (38 loc) · 883 Bytes
/
http.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
#ifndef HTTP_H
#define HTTP_H
#include <event2/listener.h>
#include <event2/bufferevent.h>
#include <event2/buffer.h>
#include <cstring>
#include <string>
#include <sys/stat.h>
#include <fcntl.h>
#include <map>
enum Status {
OK = 200,
FORBIDDEN = 403,
NOT_FOUND = 404,
BAD_REQUEST = 405,
};
enum RequestMethod{
GET,
HEAD,
UNSUPPORTED,
};
enum ContentType
{
HTML = 0, CSS, JS, JPG,
JPEG, PNG, GIF, SWF,
OTHER,
};
struct RequestInfo{
RequestMethod method;
std::string path;
RequestInfo(const RequestMethod& m, const std::string& p) : method(m), path(p) {}
const static RequestInfo BAD_REQUEST;
};
constexpr const char* SERVER = "TP-HL-SERVER";
constexpr const char* CONNECTION = "close";
constexpr const char* DOCUMENT_ROOT = "/home/andrey/projects/tp/srvroot";
void createResponse(bufferevent*);
#endif // HTTP_H