16#include "microhttpd.h"
26 " <title>SkDebugger</title>\n"
27 " <meta charset='utf-8' />\n"
28 " <meta http-equiv='X-UA-Compatible' content='IE=edge'>\n"
29 " <meta name='viewport' content='width=device-width, initial-scale=1.0'>\n"
30 " <script src='%s/res/js/core.js' type='text/javascript' charset='utf-8'></script>\n"
31 " <link href='%s/res/vul/elements.html' rel='import' />\n"
32 " <link rel='shortcut icon' href='%s/res/img/favicon.ico' type='image/x-icon'/ >"
34 "<body class='fullbleed layout vertical'>\n"
35 " <debugger-app-sk>This is the app."
36 " </debugger-app-sk>\n"
39 return debuggerTemplate;
44int SendOK(MHD_Connection* connection) {
45 const char*
data =
"";
47 MHD_Response* response = MHD_create_response_from_buffer(strlen(
data),
49 MHD_RESPMEM_PERSISTENT);
50 int ret = MHD_queue_response(connection, 200, response);
51 MHD_destroy_response(response);
55int SendError(MHD_Connection* connection,
const char* msg) {
56 MHD_Response* response = MHD_create_response_from_buffer(strlen(msg),
58 MHD_RESPMEM_PERSISTENT);
59 int ret = MHD_queue_response(connection, 500, response);
60 MHD_destroy_response(response);
65 bool setContentDisposition,
const char* dispositionString) {
66 MHD_Response* response = MHD_create_response_from_buffer(
data->size(),
67 const_cast<void*
>(
data->data()),
68 MHD_RESPMEM_MUST_COPY);
69 MHD_add_response_header(response,
"Content-Type",
type);
71 if (setContentDisposition) {
72 MHD_add_response_header(response,
"Content-Disposition", dispositionString);
75 int ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
76 MHD_destroy_response(response);
80int SendTemplate(MHD_Connection* connection,
bool redirect,
const char* redirectUrl) {
83 MHD_Response* response = MHD_create_response_from_buffer(
84 debuggerTemplate.
size(),
85 (
void*)
const_cast<char*
>(debuggerTemplate.
c_str()),
86 MHD_RESPMEM_MUST_COPY);
87 MHD_add_response_header (response,
"Access-Control-Allow-Origin",
"*");
89 int status = MHD_HTTP_OK;
92 MHD_add_response_header (response,
"Location", redirectUrl);
93 status = MHD_HTTP_SEE_OTHER;
96 int ret = MHD_queue_response(connection, status, response);
97 MHD_destroy_response(response);
static DEFINE_string(source, "https://debugger-assets.skia.org", "Where to load the web UI from.")
static SkString generate_template(SkString source)
const char * c_str() const
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
int SendData(MHD_Connection *connection, const SkData *data, const char *type, bool setContentDisposition, const char *dispositionString)
int SendTemplate(MHD_Connection *connection, bool redirect, const char *redirectUrl)
int SendOK(MHD_Connection *connection)
int SendError(MHD_Connection *connection, const char *msg)
std::shared_ptr< const fml::Mapping > data