css and other in gnu microhttpd



我使用gnu-microhttpd库开发软件,运行良好。无论如何,为了使我的html输出人性化,我想使用css和so。听起来像是犯了一个错误,但我看不出来:

所以,如果有人能帮忙的话。

string sPage;
sPage = "<html><head><link rel = "stylesheet" type = "text/css" href = "./template.css" /></head><body style="background-color:red><a href="../test1.htm">Link to this folder</a><div class="flex-container"><div>Le processus " + Process
+ " n'est pas actif, impossible de se connecter</div></div><IMG src="../images/TrafficLights.png"></body></html>";
struct MHD_Response *response;
int ret;
//response = MHD_create_response_from_buffer (strlen (page),(void*) page, MHD_RESPMEM_PERSISTENT);
response = MHD_create_response_from_buffer (strlen (sPage.c_str()),(void*) sPage.c_str(), MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
return ret;

来自MHD_queue_response:的文档

缓冲区的〔mode〕内存管理选项;如果缓冲区为静态/全局内存,则使用MHD_RESPMEM_PERSISTENT;如果缓冲区是堆分配的并且应该由MHD释放,则使用MHz RESPMEM_MUST_FREE;如果缓冲区时在瞬态内存(即堆栈上(并且必须由MHD复制,则使用MH RESPMEM-MUST_COPY;

因此,要么在某个地方静态定义sPage及其全部内容,要么保留堆栈分配的sPage,但将模式设置为MHD_RESPMEM_MUST_COPY

最新更新