11 #ifndef HTTP_SERVER_H_INCLUDED 12 #define HTTP_SERVER_H_INCLUDED 17 #include <unordered_map> 26 const unsigned int log_static_requests = 0x02;
27 const unsigned int log_static_responses = 0x04;
28 const unsigned int log_dynamic_requests = 0x08;
29 const unsigned int log_dynamic_responses = 0x10;
30 const unsigned int log_everything = 0x1f;
43 void server_start(
int port_number,
const char * base_directory);
44 void server_start(
int port_number,
const char * base_directory,
45 std::ostream & error_log,
unsigned int log_events_mask = log_everything);
73 typedef std::function<void(std::ostream &,
const std::string &,
const std::string &)>
127 typedef std::function<void(std::ostream &,
const std::string &,
const std::string &,
128 std::istream &, std::size_t,
const std::string &)>
190 std::string
url_encode(
const std::string & s);
197 std::string
url_decode(
const std::string & s);
224 std::string
header(
const std::string & mime_type,
225 std::size_t content_length = 0,
bool cache =
false);
229 #endif // HTTP_SERVER_H_INCLUDED std::string url_encode(const std::string &s)
std::string header(const std::string &mime_type, std::size_t content_length=0, bool cache=false)
std::function< void(std::ostream &, const std::string &, const std::string &)> get_action_type
Definition: http_server.h:74
Namespace with scope for all Embedded HTTP Server definitions.
Definition: http_server.h:21
const unsigned int log_connections
Bit masks for various categories of diagnostic log messages.
Definition: http_server.h:25
connection_event
Type defining possible connection events, used to notify the connection callback.
Definition: http_server.h:48
void register_connection_callback(connection_callback_type callback)
std::unordered_map< std::string, std::string > params_map_type
Type of map {key->value,...} for decoding URL and form parameters.
Definition: http_server.h:200
std::function< void(std::ostream &, const std::string &, const std::string &, std::istream &, std::size_t, const std::string &)> post_action_type
Definition: http_server.h:129
void register_text_get_action(const char *name, get_action_type f)
std::string html_encode(const std::string &s)
params_map_type decode_params(const std::string ¶ms, bool decode)
void register_html_get_action(const char *name, get_action_type f)
The given stream is to be closed and destroyed.
Definition: http_server.h:51
void server_start(int port_number, const char *base_directory)
Start the embedded HTTP server.
void register_generic_get_action(const char *name, get_action_type f)
void register_generic_post_action(const char *name, post_action_type f)
void register_html_post_action(const char *name, post_action_type f)
void register_text_post_action(const char *name, post_action_type f)
The given stream (client connection) was just created.
Definition: http_server.h:50
std::function< void(std::ostream &, connection_event)> connection_callback_type
Definition: http_server.h:58
std::string url_decode(const std::string &s)