-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebserver_https.h
More file actions
54 lines (39 loc) · 1.4 KB
/
webserver_https.h
File metadata and controls
54 lines (39 loc) · 1.4 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
#ifndef WEBSERVER_HTTPS_H
#define WEBSERVER_HTTPS_H
#include <boost/asio.hpp>
#include <boost/regex.hpp>
#include <boost/asio/ssl.hpp>
#include <thread>
#include <unordered_map>
#include "request.h"
#include "response.h"
#include "request_handler.h"
#include "echo_handler.h"
#include "static_handler.h"
#include "not_found_handler.h"
#include "status_handler.h"
using namespace std;
using namespace boost::asio;
class WebServerHTTPS {
public:
WebServerHTTPS(NginxConfig config, unsigned short port, size_t num_threads, const string& cert_file, const string& private_key_file);
void run();
private:
io_service m_io_service;
ip::tcp::endpoint endpoint;
ip::tcp::acceptor acceptor;
size_t num_threads;
vector<thread> threads;
ssl::context context;
// map from prefix to handler
unordered_map<string, shared_ptr<RequestHandler>> prefix2handler;
// map from prefix to handler_type
// used for logging the status of the server, specifically for logging prefix and handler type
unordered_map<string, string> prefix2handler_type;
void do_accept();
void process_request(shared_ptr<ssl::stream<ip::tcp::socket>> socket);
void do_reply(shared_ptr<ssl::stream<ip::tcp::socket>> socket, const unique_ptr<Request> &request);
void extract(NginxConfig config);
};
void extract_port(NginxConfig config, unsigned short& port);
#endif /* WEBSERVER_HTTPS_H */