-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestProcessor.hpp
More file actions
52 lines (44 loc) · 1.35 KB
/
Copy pathRequestProcessor.hpp
File metadata and controls
52 lines (44 loc) · 1.35 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
#pragma once
#include "Reactor.hpp"
#include "Request.hpp"
#include "RequestAnalyzer.hpp"
#include "RequestConfig.hpp"
#include "Timer.hpp"
#include <map>
#include <string>
#include <sys/epoll.h>
namespace webkernel
{
class ConnectionHandler;
class RequestProcessor
{
public:
bool analyze(int fd, std::string& buffer);
void process(int fd);
void remove_analyzer(int fd);
EventProcessingState state(int fd) const;
void set_state(int fd, EventProcessingState state);
void reset_state(int fd);
void remove_state(int fd);
bool need_to_close(int fd);
public:
RequestProcessor(ConnectionHandler* handler);
RequestProcessor(const RequestProcessor& other);
RequestProcessor& operator=(const RequestProcessor& other);
~RequestProcessor();
private:
ConnectionHandler* _handler;
std::map<int /* fd */, webshell::RequestAnalyzer> _analyzer_pool;
std::map<int /* fd */, EventProcessingState> _state;
std::map<int /* fd */, utils::Timer> _timer_pool;
std::map<int /* fd */, bool /* still alive */> _connection_pool;
private:
void _handle_virtual_host(int fd);
void _setup_timer(int fd, const webconfig::RequestConfig& config);
void _handle_keep_alive(int fd);
void _end_request(int fd);
bool _need_consume_body(webshell::Request& request);
private:
RequestProcessor();
};
} // namespace webkernel