bitz-server  2.0.1
request_handler.h
1 /*
2  * bitz-server, An ICAP server implementation in C++
3  * Copyright (C) 2012 Uditha Atukorala
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef BITZ_REQUEST_HANDLER_H
21 #define BITZ_REQUEST_HANDLER_H
22 
23 #include "modifier.h"
24 
25 #include <icap/response.h>
26 #include <icap/request.h>
27 #include <psocksxx/iosockstream.h>
28 #include <spdlog/spdlog.h>
29 
30 
31 namespace bitz {
32 
34  public:
35 
36  struct req_handler_t {
37  std::string method;
38  };
39 
40  struct handler_t {
41  std::string name;
42  Modifier::symbols_t symbols;
43  };
44 
45  RequestHandler( const std::string &method );
46  virtual ~RequestHandler();
47 
52  const std::string &method() const throw();
53 
62  virtual icap::Response * process( icap::RequestHeader * req_header, psocksxx::iosockstream * socket ) throw();
63 
64 
65  protected:
66 
67  unsigned int _handlers_count;
68  handler_t * _handlers;
69 
77  bool load_modifier( const std::string &file, Modifier::symbols_t &symbols ) throw();
78 
84  void unload_modifier( void * modifier ) throw();
85 
89  void load_modules() throw();
90 
94  void cleanup_modules() throw();
95 
105  icap::Response * process_preview( icap::Request * request, psocksxx::iosockstream * socket ) throw();
106 
113  icap::Response * process_modify( icap::Request * request ) throw();
114 
123  bool preview_continue( icap::Response * response, icap::Request * request, psocksxx::iosockstream * socket ) throw();
124 
125  private:
126 
127  req_handler_t _req_handler;
128  std::shared_ptr<spdlog::logger> _logger;
129 
130  };
131 
132 } /* end of namespace bitz */
133 
134 #endif /* !BITZ_REQUEST_HANDLER_H */
135 
Definition: request_handler.h:40
Definition: response.h:29
Definition: echo.cpp:23
icap::Response * process_preview(icap::Request *request, psocksxx::iosockstream *socket)
Definition: request_handler.cpp:232
void unload_modifier(void *modifier)
Definition: request_handler.cpp:168
void load_modules()
Definition: request_handler.cpp:174
Definition: request_header.h:31
Definition: request_handler.h:36
icap::Response * process_modify(icap::Request *request)
Definition: request_handler.cpp:309
void cleanup_modules()
Definition: request_handler.cpp:216
Definition: modifier.h:36
virtual icap::Response * process(icap::RequestHeader *req_header, psocksxx::iosockstream *socket)
Definition: request_handler.cpp:67
bool preview_continue(icap::Response *response, icap::Request *request, psocksxx::iosockstream *socket)
Definition: request_handler.cpp:353
bool load_modifier(const std::string &file, Modifier::symbols_t &symbols)
Definition: request_handler.cpp:129
Definition: request_handler.h:33
Definition: request.h:29