本文整理汇总了C++中MHD_queue_response函数的典型用法代码示例。如果您正苦于以下问题:C++ MHD_queue_response函数的具体用法?C++ MHD_queue_response怎么用?C++ MHD_queue_response使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MHD_queue_response函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: process_get_url_requert
/**
* process http get request
* @param url [request url string]
* @param connection [http connect handle]
*/
inline void process_get_url_requert(const char *url,
struct MHD_Connection * connection)
{
struct MHD_Response *response;
int fd, size, type;
if (url_to_file(url, &fd, &size, &type))
{
response =
MHD_create_response_from_fd(size, fd);
set_mime(response, type);
MHD_queue_response(connection, MHD_HTTP_OK, response);
MHD_destroy_response(response);
return;
}
else if (url_to_api(url, connection, false, NULL, 0, NULL))
return;
else
return_404(connection);
}
开发者ID:caydyn-skd,项目名称:C_HTTP,代码行数:25,代码来源:http_server.c
示例2: callback
static int
callback(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)
{
struct callback_closure *cbc = calloc(1, sizeof(struct callback_closure));
struct MHD_Response *r;
r = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, 1024,
&called_twice, cbc,
&free);
MHD_queue_response(connection, MHD_HTTP_OK, r);
MHD_destroy_response(r);
return MHD_YES;
}
开发者ID:andreyuzunov,项目名称:libmicrohttpd,代码行数:20,代码来源:test_callback.c
示例3: SendTemplate
int SendTemplate(MHD_Connection* connection, bool redirect, const char* redirectUrl) {
SkString debuggerTemplate = generate_template(SkString(FLAGS_source[0]));
MHD_Response* response = MHD_create_response_from_buffer(
debuggerTemplate.size(),
(void*) const_cast<char*>(debuggerTemplate.c_str()),
MHD_RESPMEM_MUST_COPY);
MHD_add_response_header (response, "Access-Control-Allow-Origin", "*");
int status = MHD_HTTP_OK;
if (redirect) {
MHD_add_response_header (response, "Location", redirectUrl);
status = MHD_HTTP_SEE_OTHER;
}
int ret = MHD_queue_response(connection, status, response);
MHD_destroy_response(response);
return ret;
}
开发者ID:03050903,项目名称:skia,代码行数:20,代码来源:Response.cpp
示例4: serveMasterNameXML
static int
serveMasterNameXML (const void *cls,
const char *mime,
struct Session *session,
struct MHD_Connection *connection)
{
int ret;
//char *reply;
struct MHD_Response *response;
const char *pCmd = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "Cmd");
printf("Cmd = %s\n", pCmd);
// The XML is filled up by the CommandDispatcher using a static string object.
// Since this is a .c file, we cannot use class objects here, so we basically
// extract a char point from it.
const char *pString;
// Dispatch the command
CommandDispatcher(&pString, pCmd);
//strcpy(pString, MASTER_NAME);
//sprintf(pString, reply, String);
//free(reply);
fprintf(stdout, "%s\n", pString);
/* return static form */
response = MHD_create_response_from_buffer (strlen (pString),
(void *) pString,
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:riccardoventrella,项目名称:HIDWebServer,代码行数:41,代码来源:WebServer.c
示例5: 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)
{
char buf[5],page[REPLY_PAGE_SIZE], *dyn_format_str = NULL;
char format_str[50] = "$c:$i:$o:$p0";
struct MHD_Response *response;
struct dnetc_values *shmem;
int i,ret;
if(strcmp(method,"GET") != 0)
return MHD_NO;
shmem = (struct dnetc_values *) cls;
if(!shmem->running)
{
snprintf(page,REPLY_PAGE_SIZE,"NONE");
}
else
{
MHD_get_connection_values (connection, MHD_GET_ARGUMENT_KIND, parse_http_get_param, &dyn_format_str);
if(dyn_format_str == NULL)
{
for(i=1;i<shmem->n_cpu;i++)
{
snprintf(buf,5,":$p%d",i);
strcat(format_str, buf);
}
sprint_formated_data(page,REPLY_PAGE_SIZE,format_str,shmem);
}
else
{
sprint_formated_data(page,REPLY_PAGE_SIZE,dyn_format_str,shmem);
free(dyn_format_str);
}
}
response = MHD_create_response_from_data (strlen(page), (void *) page, MHD_NO, MHD_YES);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
return ret;
}
开发者ID:lpapier,项目名称:gkrelldnet,代码行数:41,代码来源:dnetw.c
示例6: 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)
{
std::string s;
if(!strcmp(method,"POST")) {
if (*con_cls == NULL) {
*con_cls = new std::string();
return MHD_YES;
}
if (*upload_data_size) {
std::string ss(upload_data, *upload_data_size);
(*((std::string*)*con_cls)) += ss;
*upload_data_size = 0;
return MHD_YES;
}
else {
Workbench::cur()->prevent_update();
s = ((HTTPServer*)cls)->answer(url, (*((std::string*)*con_cls)));
Workbench::cur()->allow_update();
delete (std::string*)*con_cls;
*con_cls = 0;
}
}
else s = ((HTTPServer*)cls)->answer(url, "");
struct MHD_Response *response;
int ret;
char* ss = new char[s.length()+1];
strcpy(ss, s.c_str()); ss[s.length()] = 0;
response = MHD_create_response_from_buffer (strlen(ss), ss, MHD_RESPMEM_MUST_FREE);
MHD_add_response_header(response, "Access-Control-Allow-Origin", "*");
MHD_add_response_header(response, "Access-Control-Allow-Methods", "POST, GET, OPTIONS");
MHD_add_response_header(response, "Access-Control-Allow-Headers", "X-Requested-With");
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
return ret;
}
开发者ID:jfellus,项目名称:libboiboites,代码行数:41,代码来源:HTTPServer.cpp
示例7: 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
)
{ int r;
tString u=newString(url);
u.lower();
if(compare(u,pagepath)==0) {
tString s=concatenateStrings(page1,toString(stack,false),page2);
char* p=s.mbs();
MHD_Response * response = MHD_create_response_from_buffer (strlen(p),(void*)p,MHD_RESPMEM_MUST_COPY);
delete[] p;
r=MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
}
return r;
}
开发者ID:gkourtis,项目名称:napl3,代码行数:21,代码来源:microHttpd.cpp
示例8: 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, unsigned int *upload_data_size,
void **unused)
{
const char *me = cls;
struct MHD_Response *response;
int ret;
if (0 != strcmp (me, method))
return MHD_NO; /* unexpected method */
response = MHD_create_response_from_data (strlen (url),
(void *) url, MHD_NO, MHD_YES);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
return ret;
}
开发者ID:dreamsxin,项目名称:golf,代码行数:21,代码来源:daemontest_long_header.c
示例9: mhd_respond_internal
static int mhd_respond_internal(struct MHD_Connection *connection,
enum MHD_RequestTerminationCode code,
char *buffer,
size_t size,
enum MHD_ResponseMemoryMode mode) {
struct MHD_Response *response;
int r;
assert(connection);
response = MHD_create_response_from_buffer(size, buffer, mode);
if (!response)
return MHD_NO;
log_debug("Queing response %u: %s", code, buffer);
MHD_add_response_header(response, "Content-Type", "text/plain");
r = MHD_queue_response(connection, code, response);
MHD_destroy_response(response);
return r;
}
开发者ID:pwaller,项目名称:systemd,代码行数:21,代码来源:microhttpd-util.c
示例10: webu_stream_static
int webu_stream_static(struct webui_ctx *webui) {
/* Create the response for the static image request*/
int retcd;
struct MHD_Response *response;
char resp_used[20];
if (webu_stream_checks(webui) == -1) return MHD_NO;
webu_stream_cnct_count(webui);
webu_stream_mjpeg_checkbuffers(webui);
webu_stream_static_getimg(webui);
if (webui->resp_used == 0) {
MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO, _("Could not get image to stream."));
return MHD_NO;
}
response = MHD_create_response_from_buffer (webui->resp_size
,(void *)webui->resp_page, MHD_RESPMEM_MUST_COPY);
if (!response){
MOTION_LOG(ERR, TYPE_STREAM, NO_ERRNO, _("Invalid response"));
return MHD_NO;
}
if (webui->cnt->conf.stream_cors_header != NULL){
MHD_add_response_header (response, MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN
, webui->cnt->conf.stream_cors_header);
}
MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, "image/jpeg;");
snprintf(resp_used, 20, "%9ld\r\n\r\n",(long)webui->resp_used);
MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_LENGTH, resp_used);
retcd = MHD_queue_response (webui->connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
return retcd;
}
开发者ID:Motion-Project,项目名称:motion,代码行数:40,代码来源:webu_stream.c
示例11: answer
int answer (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, browser!</body></html>";
struct MHD_Response *response;
int ret;
/* Look up query parameters, filling in defaults. */
const char *lat_s = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "lat");
double lat = (lat_s == NULL) ? 0.0 : atof(lat_s);
const char *lon_s = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "lon");
double lon = (lon_s == NULL) ? 0.0 : atof(lon_s);
printf ("lat=%f lon=%f\n", lat, lon);
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:bliksemlabs,项目名称:apiserver,代码行数:22,代码来源:microserver.c
示例12: list_a_therm
int list_a_therm(struct MHD_Connection *connection, struct system_data *sysdata, int uri_num)
{
struct MHD_Response *response;
int ret;
DEBUG("\n");
if ((uri_num >=1) && (uri_num <= NUM_NODES)) {
strcpy (pagebuff, "{\n");
strcat (pagebuff, " \"therm\" :\n");
ret = print_therm_json(pagebuff, &(sysdata->nodes[uri_num-1].temp));
strcat (pagebuff, "\n}\n");
response = MHD_create_response_from_data (strlen(pagebuff), (void *) pagebuff,
MHD_NO, MHD_NO);
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
MHD_destroy_response (response);
return ret;
}
return present_error(connection, "Invalid node #: %d\n", uri_num);
}
开发者ID:cj8scrambler,项目名称:pirelay,代码行数:22,代码来源:data_handlers.c
示例13: 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)
{
int *done = cls;
struct MHD_Response *response;
int ret;
(void)version;(void)unused; /* Unused. Silent compiler warning. */
if (0 != strcmp ("PUT", method))
return MHD_NO; /* unexpected method */
if ((*done) == 0)
{
if (*upload_data_size != 8)
return MHD_YES; /* not yet ready */
if (0 == memcmp (upload_data, "Hello123", 8))
{
*upload_data_size = 0;
}
else
{
printf ("Invalid upload data `%8s'!\n", upload_data);
return MHD_NO;
}
*done = 1;
return MHD_YES;
}
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);
return ret;
}
开发者ID:Karlson2k,项目名称:libmicrohttpd,代码行数:39,代码来源:test_put.c
示例14: not_found_page
/**
* Handler used to generate a 404 reply.
*
* @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
not_found_page (const void *cls,
const char *mime,
struct Session *session,
struct MHD_Connection *connection)
{
int ret;
struct MHD_Response *response;
/* unsupported HTTP method */
response = MHD_create_response_from_buffer (strlen (NOT_FOUND_ERROR),
(void *) NOT_FOUND_ERROR,
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response (connection,
MHD_HTTP_NOT_FOUND,
response);
MHD_add_response_header (response,
MHD_HTTP_HEADER_CONTENT_ENCODING,
mime);
MHD_destroy_response (response);
return ret;
}
开发者ID:AkramAlomainy,项目名称:tinyos-main,代码行数:30,代码来源:post_example.c
示例15: send_page
static INT4 send_page (struct MHD_Connection *connection, const INT1 *page, INT4 status_code)
{
INT4 ret;
struct MHD_Response *response;
if (NULL == page)
{
return MHD_NO;
}
response = MHD_create_response_from_buffer(strlen(page), (void *) page, MHD_RESPMEM_MUST_COPY);
if (!response)
{
return MHD_NO;
}
ret = MHD_add_response_header(response, MHD_HTTP_HEADER_CONTENT_TYPE, "application/json");
ret = MHD_queue_response(connection, status_code, response);
MHD_destroy_response(response);
return ret;
}
开发者ID:PanZhangg,项目名称:DCFabric,代码行数:22,代码来源:restful-svr.c
示例16: CreateErrorResponse
int CWebServer::SendErrorResponse(struct MHD_Connection *connection, int errorType, HTTPMethod method)
{
struct MHD_Response *response = NULL;
int ret = CreateErrorResponse(connection, errorType, method, response);
if (ret == MHD_YES)
{
#ifdef WEBSERVER_DEBUG
std::multimap<std::string, std::string> headerValues;
GetRequestHeaderValues(connection, MHD_RESPONSE_HEADER_KIND, headerValues);
CLog::Log(LOGDEBUG, "webserver [OUT] HTTP %d", errorType);
for (std::multimap<std::string, std::string>::const_iterator header = headerValues.begin(); header != headerValues.end(); ++header)
CLog::Log(LOGDEBUG, "webserver [OUT] %s: %s", header->first.c_str(), header->second.c_str());
#endif
ret = MHD_queue_response(connection, errorType, response);
MHD_destroy_response(response);
}
return ret;
}
开发者ID:Karlson2k,项目名称:xbmc,代码行数:22,代码来源:WebServer.cpp
示例17: present_error
int present_error(struct MHD_Connection *connection, char * format, ...)
{
va_list args;
struct MHD_Response *response;
int ret;
DEBUG("\n");
strcpy (pagebuff, "<html><body>");
va_start (args, format);
vsnprintf (&pagebuff[strlen(pagebuff)], PAGE_BUFFER_SIZE-strlen(pagebuff), format, args);
strcat (pagebuff, "</body></html>");
response = MHD_create_response_from_data (strlen(pagebuff), (void *)pagebuff, MHD_NO, MHD_NO);
ret = MHD_queue_response (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, response);
MHD_destroy_response (response);
va_end(args);
return ret;
}
开发者ID:cj8scrambler,项目名称:pirelay,代码行数:22,代码来源:data_handlers.c
示例18: 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:KWARC,项目名称:mws,代码行数:22,代码来源:GenericHttpResponses.hpp
示例19: MHD_queue_basic_auth_fail_response
/**
* Queues a response to request basic authentication from the client
*
* @param connection The MHD connection structure
* @param realm the realm presented to the client
* @return MHD_YES on success, MHD_NO otherwise
*/
int
MHD_queue_basic_auth_fail_response (struct MHD_Connection *connection,
const char *realm,
struct MHD_Response *response)
{
int ret;
size_t hlen = strlen(realm) + strlen("Basic realm=\"\"") + 1;
char header[hlen];
snprintf (header,
sizeof (header),
"Basic realm=\"%s\"",
realm);
ret = MHD_add_response_header (response,
MHD_HTTP_HEADER_WWW_AUTHENTICATE,
header);
if (MHD_YES == ret)
ret = MHD_queue_response (connection,
MHD_HTTP_UNAUTHORIZED,
response);
return ret;
}
开发者ID:Distrotech,项目名称:libmicrohttpd,代码行数:29,代码来源:basicauth.c
示例20: ahc_cancel
static int
ahc_cancel (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;
int ret;
if (0 != strcmp ("POST", method))
{
fprintf (stderr,
"Unexpected method `%s'\n", method);
return MHD_NO;
}
if (*unused == NULL)
{
*unused = "wibble";
/* We don't want the body. Send a 500. */
response = MHD_create_response_from_buffer (0, NULL,
MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response(connection, 500, response);
if (ret != MHD_YES)
fprintf(stderr, "Failed to queue response\n");
MHD_destroy_response(response);
return ret;
}
else
{
fprintf(stderr,
"In ahc_cancel again. This should not happen.\n");
return MHD_NO;
}
}
开发者ID:Metaswitch,项目名称:libmicrohttpd,代码行数:38,代码来源:test_post.c
注:本文中的MHD_queue_response函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论