forked from YbencheL/WEBSERV
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponse_builder.hpp
More file actions
60 lines (51 loc) · 2.05 KB
/
Copy pathresponse_builder.hpp
File metadata and controls
60 lines (51 loc) · 2.05 KB
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
# ifndef RESPONSE_BUILDER_HPP
# define RESPONSE_BUILDER_HPP
# include <deque>
# include <vector>
# include <dirent.h>
# include <sys/stat.h>
# include "response.hpp"
# include "./config_parsing/includes/ConfigPars.hpp"
# include "./socket_engine.hpp"
# include "client.hpp"
# define GET_METHODE "GET"
# define POST_METHODE "POST"
# define DELETE_METHODE "DELETE"
struct client;
extern socket_engine s_engine;
class response_builder
{
private:
Client *current_client;
std::string response_holder;
std::string path;
std::string header_buff;
std::string body_buff;
bool is_body_ready;
bool is_error_page;
bool is_allowd_method(std::string method);
void path_validation(void);
std::string index_file_iterator(const std::string &full_path);
void autoindex_gen(std::vector<std::string> &dir_list, const std::string &full_path, const std::string &request_uri);
void autoindex_page(const std::string &full_path, const std::string &request_uri);
void default_error_page(unsigned short int stat_code);
std::string get_stat_code_path(unsigned int stat_code);
void generate_error_page();
void extract_host_info(std::string raw_req);
void set_static_file_res_header(off_t content_length);
void return_handling();
void set_header(void);
void set_body(void);
void handle_get();
void handle_post();
void handle_delete();
void serving_static_file();
public:
response_builder();
void init_response_builder(Client ¤t_client);
void resolve_request_path();
void validate_headers();
void build_response();
};
bool validate_headers(Client ¤t_client);
# endif