-
Notifications
You must be signed in to change notification settings - Fork 0
/
State.hpp
65 lines (51 loc) · 1.91 KB
/
State.hpp
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* State.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ychen2 <ychen2@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/10 14:14:22 by yu #+# #+# */
/* Updated: 2024/09/08 18:18:29 by ychen2 ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include "LocationConfig.hpp"
#include "Request.hpp"
#include "Response.hpp"
#include "MiddleStages.hpp"
#include "ServerConfig.hpp"
#include <stdint.h>
#include <ctime>
#include <list>
class State {
public:
State(int fd, uint32_t client_addr, int socket);
void reset_attrs();
void setup_cgi();
bool isFinishHeaders;
pid_t cgiPID;
size_t bodyPos;
size_t contentLength;
std::string request_buff;
std::string file_buff;
std::string cgi_buff;
std::string response_buff;
long bytes_sent;
std::string original_path; // to call open
std::string file_path; // to call open
std::string cgi_path; // to call execve
Request req;
Response res;
std::string client_ip_str;
int cgi_pipe_r[2], cgi_pipe_w[2];
int sock_fd, conn_fd, file_fd;
void (*stage)(std::list<State>::iterator &, const struct pollfd &, Server &);
ServerConfig server;
LocationConfig loc;
std::time_t timeCGI;
std::time_t timeEvent;
bool isCGIrunning;
// for debug:
unsigned int event_ct;
};