bitz-server  1.0.0
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 
29 
30 namespace bitz {
31 
33  public:
34 
35  struct req_handler_t {
36  std::string method;
37  };
38 
39  struct handler_t {
40  std::string name;
41  Modifier::symbols_t symbols;
42  };
43 
44  RequestHandler( const std::string &method );
45  virtual ~RequestHandler();
46 
51  const std::string &method() const throw();
52 
61  virtual icap::Response * process( icap::RequestHeader * req_header, psocksxx::iosockstream * socket ) throw();
62 
63 
64  protected:
65 
66  unsigned int _handlers_count;
67  handler_t * _handlers;
68 
76  bool load_modifier( const std::string &file, Modifier::symbols_t &symbols ) throw();
77 
83  void unload_modifier( void * modifier ) throw();
84 
88  void load_modules() throw();
89 
93  void cleanup_modules() throw();
94 
104  icap::Response * process_preview( icap::Request * request, psocksxx::iosockstream * socket ) throw();
105 
112  icap::Response * process_modify( icap::Request * request ) throw();
113 
122  bool preview_continue( icap::Response * response, icap::Request * request, psocksxx::iosockstream * socket ) throw();
123 
124  private:
125 
126  req_handler_t _req_handler;
127 
128  };
129 
130 } /* end of namespace bitz */
131 
132 #endif /* !BITZ_REQUEST_HANDLER_H */
133 
Definition: request_handler.h:39
Definition: response.h:29
Definition: echo.cpp:23
icap::Response * process_preview(icap::Request *request, psocksxx::iosockstream *socket)
Definition: request_handler.cpp:241
void unload_modifier(void *modifier)
Definition: request_handler.cpp:174
void load_modules()
Definition: request_handler.cpp:180
Definition: request_header.h:31
Definition: request_handler.h:35
icap::Response * process_modify(icap::Request *request)
Definition: request_handler.cpp:321
void cleanup_modules()
Definition: request_handler.cpp:222
Definition: modifier.h:36
virtual icap::Response * process(icap::RequestHeader *req_header, psocksxx::iosockstream *socket)
Definition: request_handler.cpp:66
bool preview_continue(icap::Response *response, icap::Request *request, psocksxx::iosockstream *socket)
Definition: request_handler.cpp:368
bool load_modifier(const std::string &file, Modifier::symbols_t &symbols)
Definition: request_handler.cpp:132
Definition: request_handler.h:32
Definition: request.h:29