-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproxy_handler.h
More file actions
40 lines (34 loc) · 1.41 KB
/
proxy_handler.h
File metadata and controls
40 lines (34 loc) · 1.41 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
#ifndef PROXY_HANDLER_H
#define PROXY_HANDLER_H
#include "request_handler.h"
#include "http_client.h"
#include "UriParser.hpp"
#include <string>
#include <sstream>
#include <iostream>
#include "googletest/googletest/include/gtest/gtest_prod.h"
class ProxyHandler : public RequestHandler {
public:
//NotFoundHandler(const std::string& reason) : reason_response(reason) {}
// Initializes the handler. Returns a response code indicating success or
// failure condition.
// uri_prefix is the value in the config file that this handler will run for.
// config is the contents of the child block for this handler ONLY.
virtual Status Init(const std::string& uri_prefix,
const NginxConfig& config);
// Handles an HTTP request, and generates a response. Returns a response code
// indicating success or failure condition. If ResponseCode is not OK, the
// contents of the response object are undefined, and the server will return
// HTTP code 500.
virtual Status HandleRequest(const Request& request,
Response* response);
private:
std::string host_;
std::string port_ = "80";
static std::string filter_request_header(const Request& req);
static std::string request_from_url(const std::string url);
FRIEND_TEST(ProxyHandlerTest,url_test);
FRIEND_TEST(ProxyHandlerTest,filter_test);
};
REGISTER_REQUEST_HANDLER(ProxyHandler);
#endif