本文整理汇总了C++中MHD_create_response_from_buffer函数的典型用法代码示例。如果您正苦于以下问题:C++ MHD_create_response_from_buffer函数的具体用法?C++ MHD_create_response_from_buffer怎么用?C++ MHD_create_response_from_buffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MHD_create_response_from_buffer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ahc_echo
static int
ahc_echo (void *cls,
struct MHD_Connection *connection,
const char *url,
const char *method,
const char *version,
const char *upload_data, size_t *upload_data_size, void **ptr)
{
struct MHD_Response *response;
char *username;
const char *password = "testpass";
const char *realm = "[email protected]";
int ret;
(void)cls; /* Unused. Silent compiler warning. */
(void)url; /* Unused. Silent compiler warning. */
(void)method; /* Unused. Silent compiler warning. */
(void)version; /* Unused. Silent compiler warning. */
(void)upload_data; /* Unused. Silent compiler warning. */
(void)upload_data_size; /* Unused. Silent compiler warning. */
(void)ptr; /* Unused. Silent compiler warning. */
username = MHD_digest_auth_get_username(connection);
if (NULL == username)
{
response = MHD_create_response_from_buffer(strlen (DENIED),
DENIED,
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_auth_fail_response(connection, realm,
MY_OPAQUE_STR,
response,
MHD_NO);
MHD_destroy_response(response);
return ret;
}
ret = MHD_digest_auth_check(connection, realm,
username,
password,
300);
MHD_free (username);
if ( (ret == MHD_INVALID_NONCE) ||
(ret == MHD_NO) )
{
response = MHD_create_response_from_buffer(strlen (DENIED),
DENIED,
MHD_RESPMEM_PERSISTENT);
if (NULL == response)
return MHD_NO;
ret = MHD_queue_auth_fail_response(connection, realm,
MY_OPAQUE_STR,
response,
(ret == MHD_INVALID_NONCE) ? MHD_YES : MHD_NO);
MHD_destroy_response(response);
return ret;
}
response = MHD_create_response_from_buffer(strlen(PAGE), PAGE,
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
MHD_destroy_response(response);
return ret;
}
开发者ID:Karlson2k,项目名称:libmicrohttpd,代码行数:60,代码来源:digest_auth_example.c
示例2: answer_to_connection
int answer_to_connection(
void* cls,
struct MHD_Connection* connection,
const char* url,
const char* method,
const char* version,
const char* upload_data,
size_t* upload_data_size,
void** con_cls)
{
char* user;
char* pass;
int authorized;
struct MHD_Response* response;
int ret;
if (strncmp(method, "GET", 4) != 0) {
return MHD_NO;
}
if (*con_cls == NULL) {
*con_cls = connection;
return MHD_YES;
}
pass = NULL;
user = MHD_basic_auth_get_username_password(connection, &pass);
authorized = (user != NULL)
&& (strncmp(user, USER, strlen(USER)) == 0)
&& (strncmp(pass, PASSWORD, strlen(PASSWORD)) == 0);
if (user != NULL) {
free(user);
}
if (pass != NULL) {
free(pass);
}
if (authorized) {
const char* page = "<html><body>Authorized!</body></html>";
response = MHD_create_response_from_buffer(
strlen(page),
(void*)page,
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
} else {
const char* page = "<html><body>Unauthorized!</body></html>";
response = MHD_create_response_from_buffer(
strlen(page),
(void*)page,
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_basic_auth_fail_response(
connection,
"Tutorial Example 5 Realm",
response);
}
MHD_destroy_response(response);
return ret;
}
开发者ID:proidiot,项目名称:old-websites,代码行数:59,代码来源:answer.c
示例3: Private
Private() : mhd(0)
{
acceptPolicy = [](const QHostAddress &addr) { return addr.isLoopback(); };
const char *msg404 = "<html><body>404 - Page not found</body></html>";
response404 = MHD_create_response_from_buffer(strlen(msg404), const_cast<char*>(msg404), MHD_RESPMEM_PERSISTENT);
const char *msg401 = "<html><body>401 - Unauthorized</body></html>";
response401 = MHD_create_response_from_buffer(strlen(msg401), const_cast<char*>(msg401), MHD_RESPMEM_PERSISTENT);
}
开发者ID:LionsPhil,项目名称:Drawpile,代码行数:9,代码来源:qmhttp.cpp
示例4: ahc_echo
static int
ahc_echo (void *cls,
struct MHD_Connection *connection,
const char *url,
const char *method,
const char *version,
const char *upload_data, size_t *upload_data_size,
void **unused)
{
struct MHD_Response *response;
char *username;
const char *password = "testpass";
const char *realm = "[email protected]";
int ret;
username = MHD_digest_auth_get_username(connection);
if ( (username == NULL) ||
(0 != strcmp (username, "testuser")) )
{
response = MHD_create_response_from_buffer(strlen (DENIED),
DENIED,
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_auth_fail_response(connection, realm,
OPAQUE,
response,
MHD_NO);
MHD_destroy_response(response);
return ret;
}
ret = MHD_digest_auth_check(connection, realm,
username,
password,
300);
free(username);
if ( (ret == MHD_INVALID_NONCE) ||
(ret == MHD_NO) )
{
response = MHD_create_response_from_buffer(strlen (DENIED),
DENIED,
MHD_RESPMEM_PERSISTENT);
if (NULL == response)
return MHD_NO;
ret = MHD_queue_auth_fail_response(connection, realm,
OPAQUE,
response,
(ret == MHD_INVALID_NONCE) ? MHD_YES : MHD_NO);
MHD_destroy_response(response);
return ret;
}
response = MHD_create_response_from_buffer(strlen(PAGE), PAGE,
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
MHD_destroy_response(response);
return ret;
}
开发者ID:Distrotech,项目名称:libmicrohttpd,代码行数:55,代码来源:test_digestauth_with_arguments.c
示例5: ahc_echo
static int
ahc_echo (void *cls,
struct MHD_Connection *connection,
const char *url,
const char *method,
const char *version,
const char *upload_data, size_t *upload_data_size, void **ptr)
{
static int aptr;
const char *me = cls;
struct MHD_Response *response;
int ret;
char *user;
char *pass;
int fail;
if (0 != strcmp (method, "GET"))
return MHD_NO; /* unexpected method */
if (&aptr != *ptr)
{
/* do never respond on first call */
*ptr = &aptr;
return MHD_YES;
}
*ptr = NULL; /* reset when done */
/* require: "Aladdin" with password "open sesame" */
pass = NULL;
user = MHD_basic_auth_get_username_password (connection, &pass);
fail = ( (user == NULL) || (0 != strcmp (user, "Aladdin")) || (0 != strcmp (pass, "open sesame") ) );
if (fail)
{
response = MHD_create_response_from_buffer (strlen (DENIED),
(void *) DENIED,
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_basic_auth_fail_response (connection,"TestRealm",response);
}
else
{
response = MHD_create_response_from_buffer (strlen (me),
(void *) me,
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
}
if (NULL != user)
free (user);
if (NULL != pass)
free (pass);
MHD_destroy_response (response);
return ret;
}
开发者ID:Paxxi,项目名称:libmicrohttpd,代码行数:51,代码来源:authorization_example.c
示例6: ahc_echo
static int
ahc_echo (void *cls,
struct MHD_Connection *connection,
const char *url,
const char *method,
const char *version,
const char *upload_data, size_t *upload_data_size, void **ptr)
{
static int aptr;
const char *me = cls;
struct MHD_Response *response;
int ret;
if (0 != strcmp (method, "GET"))
return MHD_NO; /* unexpected method */
if (&aptr != *ptr)
{
/* do never respond on first call */
*ptr = &aptr;
return MHD_YES;
}
*ptr = NULL; /* reset when done */
response = MHD_create_response_from_buffer (strlen (me),
(void *) me,
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
return ret;
}
开发者ID:AlgoPeek,项目名称:libmicrohttpd,代码行数:29,代码来源:minimal_example.c
示例7: main
int
main (int argc, char *const *argv)
{
unsigned int errorCount = 0;
int port = 1081;
oneone = (NULL != strrchr (argv[0], (int) '/')) ?
(NULL != strstr (strrchr (argv[0], (int) '/'), "11")) : 0;
if (0 != curl_global_init (CURL_GLOBAL_WIN32))
return 2;
response = MHD_create_response_from_buffer (strlen ("/hello_world"),
"/hello_world",
MHD_RESPMEM_MUST_COPY);
errorCount += testExternalGet (port++);
errorCount += testInternalGet (port++, 0);
errorCount += testMultithreadedGet (port++, 0);
errorCount += testMultithreadedPoolGet (port++, 0);
if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_POLL))
{
errorCount += testInternalGet(port++, MHD_USE_POLL);
errorCount += testMultithreadedGet(port++, MHD_USE_POLL);
errorCount += testMultithreadedPoolGet(port++, MHD_USE_POLL);
}
if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_EPOLL))
{
errorCount += testInternalGet(port++, MHD_USE_EPOLL_LINUX_ONLY);
errorCount += testMultithreadedPoolGet(port++, MHD_USE_EPOLL_LINUX_ONLY);
}
MHD_destroy_response (response);
if (errorCount != 0)
fprintf (stderr, "Error (code: %u)\n", errorCount);
curl_global_cleanup ();
return errorCount != 0; /* 0 == pass */
}
开发者ID:Metaswitch,项目名称:libmicrohttpd,代码行数:34,代码来源:perf_get.c
示例8: send_xml
/**
* Add an XML response to the queue of the server
*
* @param connection The client connection which will receive the response
*
* @param xmlbuff The XML to send
*
* @return MHD return value, MHD_NO if the response failed to be created,
* return code of MHD_queue_response otherwise
*/
static int
send_xml ( struct MHD_Connection *connection, char *xmlbuff )
{
int ret;
struct MHD_Response *response;
if( !xmlbuff )
{
printf("The XML that is attempted to send is NULL\n");
return MHD_NO;
}
response = MHD_create_response_from_buffer (strlen(xmlbuff), xmlbuff, MHD_RESPMEM_MUST_FREE);
if( !response )
{
if( xmlbuff )
free( xmlbuff );
return MHD_NO;
}
MHD_add_response_header ( response, "Content-Type", "text/xml" );
ret = MHD_queue_response ( connection, MHD_HTTP_OK, response );
MHD_destroy_response( response );
return ret;
}
开发者ID:Rustor,项目名称:HomeAutomationBridgeZ,代码行数:39,代码来源:hpd_http_web_server.c
示例9: sendMethodNotAllowedResponse
inline int sendMethodNotAllowedResponse(struct MHD_Connection* connection, bool allowGet) {
struct MHD_Response* response;
int ret;
#ifdef MICROHTTPD_DEPRECATED
response = MHD_create_response_from_data(
strlen(XML_MWS_METHOD_NOT_ALLOWED), (void*)XML_MWS_METHOD_NOT_ALLOWED, false, false);
#else // MICROHTTPD_DEPRECATED
response = MHD_create_response_from_buffer(
strlen(XML_MWS_METHOD_NOT_ALLOWED), (void*)XML_MWS_METHOD_NOT_ALLOWED, MHD_RESPMEM_PERSISTENT);
#endif // MICROHTTPD_DEPRECATED
MHD_add_response_header(response, "Content-Type", "text/xml");
MHD_add_response_header(response, "Allow",
allowGet ? "GET, POST, OPTIONS" : "POST, OPTIONS");
MHD_add_response_header(response, "Access-Control-Allow-Origin", "*");
MHD_add_response_header(response, "Allow",
allowGet ? "GET, POST, OPTIONS" : "POST, OPTIONS");
MHD_add_response_header(response, "Access-Control-Allow-Headers",
"CONTENT-TYPE");
MHD_add_response_header(response, "Access-Control-Max-Age", "1728000");
ret = MHD_queue_response(connection, MHD_HTTP_METHOD_NOT_ALLOWED, response);
MHD_destroy_response(response);
return ret;
}
开发者ID:KWARC,项目名称:mws,代码行数:25,代码来源:GenericHttpResponses.hpp
示例10: sendOptionsResponse
inline int
sendOptionsResponse(struct MHD_Connection* connection)
{
struct MHD_Response* response;
int ret;
#ifdef MICROHTTPD_DEPRECATED
response = MHD_create_response_from_data(strlen(EMPTY_RESPONSE),
(void*) EMPTY_RESPONSE,
false,
false);
#else // MICROHTTPD_DEPRECATED
response = MHD_create_response_from_buffer(strlen(EMPTY_RESPONSE),
(void*) EMPTY_RESPONSE,
MHD_RESPMEM_PERSISTENT);
#endif // MICROHTTPD_DEPRECATED
MHD_add_response_header(response,
"Content-Type", "text/plain");
MHD_add_response_header(response,
"Access-Control-Allow-Origin", "*");
MHD_add_response_header(response,
"Access-Control-Allow-Methods", "POST, OPTIONS");
MHD_add_response_header(response,
"Access-Control-Allow-Headers", "CONTENT-TYPE");
MHD_add_response_header(response,
"Access-Control-Max-Age", "1728000");
ret = MHD_queue_response(connection,
MHD_HTTP_OK,
response);
MHD_destroy_response(response);
return ret;
}
开发者ID:Zwackelmann,项目名称:mws,代码行数:33,代码来源:GenericResponses.hpp
示例11: sendXmlGenericResponse
inline int
sendXmlGenericResponse(struct MHD_Connection* connection,
const char* xmlGenericResponse,
int statusCode)
{
struct MHD_Response* response;
int ret;
#ifdef MICROHTTPD_DEPRECATED
response = MHD_create_response_from_data(strlen(xmlGenericResponse),
(void*) xmlGenericResponse,
/* must_free = */ 0,
/* must_copy = */ 0);
#else // MICROHTTPD_DEPRECATED
response = MHD_create_response_from_buffer(strlen(xmlGenericResponse),
(void*) xmlGenericResponse,
MHD_RESPMEM_PERSISTENT);
#endif // MICROHTTPD_DEPRECATED
MHD_add_response_header(response,
"Content-Type", "text/xml");
ret = MHD_queue_response(connection,
statusCode,
response);
MHD_destroy_response(response);
return ret;
}
开发者ID:Zwackelmann,项目名称:mws,代码行数:27,代码来源:GenericResponses.hpp
示例12: serve_simple_form
/**
* Handler that returns a simple static HTTP page that
* is passed in via 'cls'.
*
* @param cls a 'const char *' with the HTML webpage to return
* @param mime mime type to use
* @param session session handle
* @param connection connection to use
*/
static int
serve_simple_form (const void *cls,
const char *mime,
struct Session *session,
struct MHD_Connection *connection)
{
int ret;
const char *form = cls;
struct MHD_Response *response;
/* return static form */
response = MHD_create_response_from_buffer (strlen (form),
(void *) form,
MHD_RESPMEM_PERSISTENT);
if (NULL == response)
return MHD_NO;
add_session_cookie (session, response);
MHD_add_response_header (response,
MHD_HTTP_HEADER_CONTENT_ENCODING,
mime);
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
MHD_destroy_response (response);
return ret;
}
开发者ID:Chris112,项目名称:sep,代码行数:35,代码来源:post_example.c
示例13: JsSubmitResponse
/*
将response提交到queue中, 并且销毁
*/
int JsSubmitResponse(struct JsObject* obj){
if(strcmp(obj->Class,"Response")!=0)
JsThrowString("The Object Is't Response");
struct JsResponse* response = (struct JsResponse*)obj->sb[JS_RESPONSE_FLOOR];
if(response == NULL)
JsThrowString("The Response Is Burned");
struct MHD_Response *HTMLResponse = NULL;
//构建HTML response
HTMLResponse = MHD_create_response_from_buffer (response->bUsed,
(void *) response->body,
MHD_RESPMEM_MUST_COPY);
//配置header
int i;
for(i=0;i<response->hUsed;++i){
MHD_add_response_header (HTMLResponse, response->header[i].key, response->header[i].value);
}
//配置状态码
int ret = MHD_queue_response (response->connection, response->code, HTMLResponse);
MHD_destroy_response (HTMLResponse);
//释放内存
free(response->body);
for(i=0;i<response->hUsed;++i){
free(response->header[i].key);
free(response->header[i].value);
}
free(response->header);
free(response);
obj->sb[JS_RESPONSE_FLOOR] = NULL;
return ret;
}
开发者ID:darkfireworld,项目名称:c-javascript-engine,代码行数:37,代码来源:JsResponse.c
示例14: ahc_empty
static int
ahc_empty (void *cls,
struct MHD_Connection *connection,
const char *url,
const char *method,
const char *version,
const char *upload_data, size_t *upload_data_size,
void **unused)
{
static int ptr;
struct MHD_Response *response;
int ret;
if (0 != strcmp ("GET", method))
return MHD_NO; /* unexpected method */
if (&ptr != *unused)
{
*unused = &ptr;
return MHD_YES;
}
*unused = NULL;
response = MHD_create_response_from_buffer (0,
NULL,
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
if (ret == MHD_NO)
abort ();
return ret;
}
开发者ID:andreyuzunov,项目名称:libmicrohttpd,代码行数:30,代码来源:test_get.c
示例15: ahc_echo
static int
ahc_echo (void *cls,
struct MHD_Connection *connection,
const char *url,
const char *method,
const char *version,
const char *upload_data, size_t *upload_data_size,
void **mptr)
{
static int marker;
struct MHD_Response *response;
int ret;
if (0 != strcmp ("POST", method))
{
printf ("METHOD: %s\n", method);
return MHD_NO; /* unexpected method */
}
if ((*mptr != NULL) && (0 == *upload_data_size))
{
if (*mptr != &marker)
abort ();
response = MHD_create_response_from_buffer (2, "OK",
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
*mptr = NULL;
return ret;
}
if (strlen (POST_DATA) != *upload_data_size)
return MHD_YES;
*upload_data_size = 0;
*mptr = ▮
return MHD_YES;
}
开发者ID:andreyuzunov,项目名称:libmicrohttpd,代码行数:35,代码来源:test_post_loop.c
示例16: sendAccessControl
/*
*The Cross-Origin Resource Sharing standard works by adding new HTTP headers
*that allow servers to describe the set of origins that are permitted to read
*that information using a web browser. Additionally, for HTTP request methods
*that can cause side-effects on user data (in particular, for HTTP methods
*other than GET, or for POST usage with certain MIME types), the specification
*mandates that browsers "preflight" the request, soliciting supported methods
*from the server with an HTTP OPTIONS request header, and then, upon
*"approval" from the server, sending the actual request with the actual HTTP
*request method. Servers can also notify clients whether "credentials"
*(including Cookies and HTTP Authentication data) should be sent with
*requests.
*/
static int sendAccessControl(struct MHD_Connection *connection, const char *url,
const char *method, const char *version)
{
int ret;
struct MHD_Response *response;
std::cout << "Sending CORS accept header for the request: " << std::endl;
/*answer_to_connection(NULL, connection, url, method, version, NULL, NULL,
NULL);*/
response = MHD_create_response_from_buffer(0, NULL, MHD_RESPMEM_PERSISTENT);
if (response == 0)
{
return MHD_NO;
}
// not too fussed with who is trying to use us :)
MHD_add_response_header(response, "Access-Control-Allow-Origin", "*");
// only allow GET (and OPTIONS) requests, no need for PUSH yet...now there is a need for push
MHD_add_response_header(response, "Access-Control-Allow-Methods",
"GET, OPTIONS, POST"); // see http://stackoverflow.com/questions/107390/whats-the-difference-between-a-post-and-a-put-http-request
// we simply 'allow' all requested headers
const char* val = MHD_lookup_connection_value(connection, MHD_HEADER_KIND,
"Access-Control-Request-Headers");
MHD_add_response_header(response, "Access-Control-Allow-Headers", val);
// these seem to be needed?
MHD_add_response_header(response, "Access-Control-Expose-Headers",
"Content-Range");
ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
MHD_destroy_response(response);
return ret;
}
开发者ID:nickerso,项目名称:web-service-demo,代码行数:46,代码来源:libhttpd-utils.cpp
示例17: fill_s_reply
/**
* Send the 'SUBMIT_PAGE'.
*
* @param info information string to send to the user
* @param request request information
* @param connection connection to use
*/
static int
fill_s_reply (const char *info,
struct Request *request,
struct MHD_Connection *connection)
{
int ret;
char *reply;
struct MHD_Response *response;
GNUNET_asprintf (&reply,
SUBMIT_PAGE,
info,
info);
/* return static form */
response = MHD_create_response_from_buffer (strlen (reply),
(void *) reply,
MHD_RESPMEM_MUST_FREE);
MHD_add_response_header (response,
MHD_HTTP_HEADER_CONTENT_TYPE,
MIME_HTML);
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
MHD_destroy_response (response);
return ret;
}
开发者ID:muggenhor,项目名称:GNUnet,代码行数:33,代码来源:gnunet-namestore-fcfsd.c
示例18: answer_to_connection
static int
answer_to_connection(void *cls,
struct MHD_Connection *connection,
const char *url,
const char *method,
const char *version,
const char *upload_data,
size_t *upload_data_size,
void **con_cls)
{
const char *page = "<html><body>Hello timeout!</body></html>";
struct MHD_Response *response;
int ret;
(void)cls; /* Unused. Silent compiler warning. */
(void)url; /* Unused. Silent compiler warning. */
(void)version; /* Unused. Silent compiler warning. */
(void)method; /* Unused. Silent compiler warning. */
(void)upload_data; /* Unused. Silent compiler warning. */
(void)upload_data_size; /* Unused. Silent compiler warning. */
(void)con_cls; /* Unused. Silent compiler warning. */
response = MHD_create_response_from_buffer (strlen(page),
(void *) page,
MHD_RESPMEM_PERSISTENT);
MHD_add_response_header (response,
MHD_HTTP_HEADER_CONTENT_TYPE,
"text/html");
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
response);
MHD_destroy_response(response);
return ret;
}
开发者ID:Karlson2k,项目名称:libmicrohttpd,代码行数:33,代码来源:timeout.c
示例19: mhd_ahc
static int
mhd_ahc (void *cls,
struct MHD_Connection *connection,
const char *url,
const char *method,
const char *version,
const char *upload_data, size_t *upload_data_size,
void **unused)
{
static int ptr;
struct MHD_Response *response;
int ret;
if (0 != strcmp ("GET", method))
return MHD_NO; /* unexpected method */
if (&ptr != *unused)
{
*unused = &ptr;
return MHD_YES;
}
*unused = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MHD sends respose for request to URL `%s'\n", url);
response = MHD_create_response_from_buffer (strlen (url),
(void *) url,
MHD_RESPMEM_MUST_COPY);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
if (ret == MHD_NO)
abort ();
return ret;
}
开发者ID:tg-x,项目名称:gnunet,代码行数:31,代码来源:test_gns_proxy.c
示例20: answer_to_connection
static int
answer_to_connection(void *cls,
struct MHD_Connection *connection,
const char *url,
const char *method,
const char *version,
const char *upload_data, size_t *upload_data_size,
void **con_cls)
{
const char *page = "<html><body>Hello, World!</body></html>";
struct MHD_Response *response;
int ret;
fprintf(stderr, "respond to %s %s\n", method, url);
response =
MHD_create_response_from_buffer(strlen(page), (void *)page,
MHD_RESPMEM_PERSISTENT);
ret =
MHD_queue_response(connection, MHD_HTTP_OK, response);
MHD_destroy_response(response);
return ret;
}
开发者ID:kuangsan,项目名称:openshift-diy-binhello-demo,代码行数:25,代码来源:binhello.c
注:本文中的MHD_create_response_from_buffer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论