-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrequest_handler_proxy.h
41 lines (31 loc) · 1.04 KB
/
request_handler_proxy.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
#ifndef PROXY_HANDLER_H
#define PROXY_HANDLER_H
#include "request_handler.h"
#include "response_parser.h"
#include <iostream>
#include <boost/asio.hpp>
namespace http {
namespace server {
class ProxyHandler : public RequestHandler {
public:
Status Init(const std::string& uri_prefix, const NginxConfig& config) override;
Status HandleRequest(const Request& request, Response* response) override;
private:
ResponseParser resp_parser;
// domain name of host to proxy
std::string host_;
// port num as a string
std::string port_;
// path to server
std::string path_;
// uri prefix passed in Init
std::string uri_prefix_;
// makes request to given host and returns raw response
// handles 302 error
bool make_request(std::string host, std::string port, std::string path, bool redirect, Response* res);
void parse_url(std::string url, std::string& host, std::string& port, std::string& path);
};
REGISTER_REQUEST_HANDLER(ProxyHandler);
} // namespace server
} // namespace http
#endif // PROXY_HANDLER_H