-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCGIManager.h
89 lines (65 loc) · 1.49 KB
/
CGIManager.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// Created by user on 19-4-11.
//
#ifndef WEBSERVER_CGIMANAGER_H
#define WEBSERVER_CGIMANAGER_H
#include <linux/sockios.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/eventfd.h>
#include <sys/epoll.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <thread>
#include <map>
#include "FastCGI.h"
#include "Array.h"
#include "HTTPParse.h"
namespace RequestParams {
extern char *filename;
extern char *method;
extern char *query;
extern char *referer;
extern char *contentType;
extern char *contentLength;
extern char *cookie;
extern char *null;
}
class CGIManager {
public:
CGIManager();
~CGIManager();
bool Init();
bool BeginRequest(int fd);
bool Request(HTTPRequest *header);
bool Response();
int GetFD();
void SetMonitors(std::unordered_map<int, HTTPRequest> *monitors);
void SetEpoll(int fd);
private:
bool FCGIConnect();
void ParamsReset();
private:
int cgifd;
FCGI_BeginRequest beginRequest;
char msg[100];
int efd;
bool exit; //not thread safe
std::map<int, long long> record;
std::unordered_map<int, HTTPRequest> *map;
std::thread listen;
int epfd;
PoolHeader *pool;
PoolHeader *recvPool;
Array *array;
FCGI_Header *responseHeader;
char contentLength[10];
char *params[8][2];
};
#endif //WEBSERVER_CGIMANAGER_H