2 * @file http_protocol_module_base.h
3 * @brief shared object http protocol module abstract class
5 * L7VSD: Linux Virtual Server for Layer7 Load Balancing
6 * Copyright (C) 2009 NTT COMWARE Corporation.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 **********************************************************************/
24 #ifndef HTTP_PROTOCOL_MODULE_BASE_H
25 #define HTTP_PROTOCOL_MODULE_BASE_H
27 #include "protocol_module_base.h"
32 class http_protocol_module_base : public protocol_module_base
35 //! @enum CHECK_RESULT_TAG
36 //! @brief check tag is return to http protocol module.
37 enum CHECK_RESULT_TAG {
38 CHECK_OK = 0, //!< check ok
39 CHECK_NG, //!< check NG
40 CHECK_IMPOSSIBLE //!< check impossible
43 //! check http method function
44 //! @param const char* buffer
45 //! @param const size_t buffer_len
46 //! @return CHECK_RESULT_TAG http method is valid
47 CHECK_RESULT_TAG check_http_method(const char *, const size_t);
49 //! check http version function
50 //! @param const char* buffer
51 //! @param const size_t buffer_len
52 //! @return CHECK_RESULT_TAG http version 1.0 or 1.1
53 CHECK_RESULT_TAG check_http_version(const char *, const size_t);
55 //! check http status code function
56 //! @param const char* buffer
57 //! @param const size_t buffer_len
58 //! @return CHECK_RESULT_TAG status code is normal or error
59 CHECK_RESULT_TAG check_status_code(const char *, const size_t);
61 //! check http method and version function
62 //! @param const char* buffer
63 //! @param const size_t buffer_len
64 //! @return CHECK_RESULT_TAG http method and version is valid
65 CHECK_RESULT_TAG check_http_method_and_version(const char *, const size_t);
67 //! check http version and status code function
68 //! @param const char* buffer
69 //! @param const size_t buffer_len
70 //! @return CHECK_RESULT_TAG http version and status code is valid
71 CHECK_RESULT_TAG check_http_version_and_status_code(const char *, const size_t);
73 //! search uri function
74 //! @param const char* buffer
75 //! @param const size_t buffer_len
76 //! @param size_t& uri offset
77 //! @param size_t& uri length
78 //! @return bool find is true. not find is false
79 bool find_uri(const char *, const size_t, size_t &, size_t &);
81 //! search status function
82 //! @param const char* buffer
83 //! @param const size_t buffer_len
84 //! @param size_t& status offset
85 //! @param size_t& status length
86 //! @return bool find is true. not find is false
87 bool find_status_code(const char *, const size_t, size_t &, size_t &);
89 //! search http header function
90 //! @param const char* buffer
91 //! @param const size_t buffer_len
92 //! @param const string& header name
93 //! @param size_t& header offset
94 //! @param size_t& header length
95 //! @return bool find is true. not find is false
96 bool find_http_header(const char *, const size_t, const std::string &, size_t &, size_t &);
98 //! search http header Cookie function
99 //! @param const char* buffer
100 //! @param const size_t buffer_len
101 //! @param size_t& header offset
102 //! @param size_t& header length
103 //! @return bool find is true. not find is false
104 bool find_http_header_cookie(const char *, const size_t, size_t &, size_t &);
106 //! search http header Content_Length function
107 //! @param const char* buffer
108 //! @param const size_t buffer_len
109 //! @param size_t& header offset
110 //! @param size_t& header length
111 //! @return bool find is true. not find is false
112 bool find_http_header_content_length(const char *, const size_t, size_t &, size_t &);
114 //! search http header X_Forwarded_For function
115 //! @param const char* buffer
116 //! @param const size_t buffer_len
117 //! @param size_t& header offset
118 //! @param size_t& header length
119 //! @return bool find is true. not find is false
120 bool find_http_header_x_forwarded_for(const char *, const size_t, size_t &, size_t &);
122 //! search http header all function
123 //! @param const char* buffer
124 //! @param const size_t buffer_len
125 //! @param size_t& header offset
126 //! @param size_t& header length
127 //! @return bool find is true. not find is false
128 bool find_http_header_all(const char *, const size_t, size_t &, size_t &);
130 //! check http get method
131 //! @param const char* buffer
132 //! @return bool get method is true. other is false
133 bool is_get_request(const char *buffer);
135 //! check http post method
136 //! @param const char* buffer
137 //! @return bool post method is true. other is false
138 bool is_post_request(const char *buffer);
140 //! increment http statistics
141 //! @param const char* buffer
142 void increment_stats(const char *buffer);
144 //! http statistic information
145 http_stats http_stats_info;
150 http_protocol_module_base(std::string in_modulename) : protocol_module_base(in_modulename) {};
153 virtual ~http_protocol_module_base() {};
155 //! get base statistic object.
156 //! @return base statistic object.
157 stats_base& get_stats()
159 return http_stats_info;
165 #endif //HTTP_PROTOCOL_MODULE_BASE_H