30 #ifndef _HTTP_SERVER_H_ 31 #define _HTTP_SERVER_H_ 33 #include <boost/optional/optional.hpp> 40 #undef ELECTRONEUM_DEFAULT_LOG_CATEGORY 41 #define ELECTRONEUM_DEFAULT_LOG_CATEGORY "net.http" 65 template<
class t_connection_context = net_utils::connection_context_base>
93 virtual bool handle_recv(
const void* ptr,
size_t cb);
98 http_state_retriving_comand_line,
99 http_state_retriving_header,
100 http_state_retriving_body,
101 http_state_connection_close,
105 enum body_transfer_type{
106 http_body_transfer_chunked,
107 http_body_transfer_measure,
108 http_body_transfer_chunked_instead_measure,
109 http_body_transfer_connection_close,
110 http_body_transfer_multipart,
111 http_body_transfer_undefined
116 bool analize_cached_request_header_and_invoke_state(
size_t pos);
118 bool handle_invoke_query_line();
119 bool parse_cached_header(http_header_info& body_info,
const std::string& m_cache_to_process,
size_t pos);
120 std::string::size_type match_end_of_header(
const std::string&
buf);
121 bool get_len_from_content_lenght(
const std::string& str,
size_t& len);
122 bool handle_retriving_query_body();
123 bool handle_query_measure();
124 bool set_ready_state();
137 machine_state m_state;
138 body_transfer_type m_body_transfer_type;
139 bool m_is_stop_handling;
141 size_t m_len_summary, m_len_remain;
150 template<
class t_connection_context>
156 t_connection_context& m_conn_context) = 0;
161 template<
class t_connection_context>
165 std::function<void(size_t, uint8_t*)>
rng;
172 template<
class t_connection_context = net_utils::connection_context_base>
195 response.m_mime_tipe =
"text/plain";
205 return m_config.
m_phandler->init_server_thread();;
210 return m_config.
m_phandler->deinit_server_thread();
228 #include "http_protocol_handler.inl" 230 #endif //_HTTP_SERVER_H_ virtual bool thread_deinit()
boost::optional< http_response_info > get_response(const http_request_info &request)
virtual bool thread_deinit()
std::function< void(size_t, uint8_t *)> rng
virtual bool handle_recv(const void *ptr, size_t cb)
epee::misc_utils::struct_init< response_t > response
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
virtual ~simple_http_connection_handler()
bool handle_request(const http_request_info &query_info, http_response_info &response)
t_connection_context & m_conn_context
boost::optional< login > m_user
virtual bool init_server_thread()
virtual bool thread_init()
simple_http_connection_handler(i_service_endpoint *psnd_hndlr, config_type &config, t_connection_context &conn_context)
virtual bool handle_request(const http::http_request_info &query_info, http_response_info &response)
i_http_server_handler< t_connection_context > * m_phandler
http_server_config config_type
bool after_init_connection()
http_custom_handler(i_service_endpoint *psnd_hndlr, config_type &config, t_connection_context &conn_context)
void handle_qued_callback()
const T & move(const T &t)
virtual ~i_http_server_handler()
i_service_endpoint * m_psnd_hndlr
virtual bool thread_init()
std::vector< std::string > m_access_control_origins
bool after_init_connection()
virtual bool deinit_server_thread()
Implements RFC 2617 digest auth. Digests from RFC 7616 can be added.
virtual bool handle_http_request(const http_request_info &query_info, http_response_info &response, t_connection_context &m_conn_context)=0
custum_handler_config< t_connection_context > config_type
t_connection_context connection_context