23 #include <microhttpd.h> 39 bool SafeHttpServer::SendResponse(
string const& _response,
void* _addInfo)
42 struct MHD_Response *result = MHD_create_response_from_buffer(
44 static_cast<void *
>(
const_cast<char *
>(_response.c_str())),
48 MHD_add_response_header(result,
"Content-Type",
"application/json");
49 MHD_add_response_header(result,
"Access-Control-Allow-Origin", m_allowedOrigin.c_str());
51 int ret = MHD_queue_response(client_connection->
connection, client_connection->
code, result);
52 MHD_destroy_response(result);
53 return ret == MHD_YES;
56 bool SafeHttpServer::SendOptionsResponse(
void* _addInfo)
59 struct MHD_Response *result = MHD_create_response_from_buffer(0,
nullptr, MHD_RESPMEM_MUST_COPY);
61 MHD_add_response_header(result,
"Allow",
"POST, OPTIONS");
62 MHD_add_response_header(result,
"Access-Control-Allow-Origin", m_allowedOrigin.c_str());
63 MHD_add_response_header(result,
"Access-Control-Allow-Headers",
"origin, content-type, accept");
64 MHD_add_response_header(result,
"DAV",
"1");
66 int ret = MHD_queue_response(client_connection->
connection, client_connection->
code, result);
67 MHD_destroy_response(result);
68 return ret == MHD_YES;
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
struct MHD_PostProcessor * postprocessor
std::hash for asio::adress
structure copied from libjson-rpc-cpp httpserver version 0.6.0
MHD_Connection * connection
jsonrpc::HttpServer * server