本文整理汇总了C++中HttpRequest::SetInFlight方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpRequest::SetInFlight方法的具体用法?C++ HttpRequest::SetInFlight怎么用?C++ HttpRequest::SetInFlight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpRequest
的用法示例。
在下文中一共展示了HttpRequest::SetInFlight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleRequest
/**
* Called whenever a new request is made. This sets up HttpRequest &
* HttpResponse objects and then calls DispatchRequest.
*/
static int HandleRequest(void *http_server_ptr,
struct MHD_Connection *connection,
const char *url,
const char *method,
const char *version,
const char *upload_data,
size_t *upload_data_size,
void **ptr) {
HttpServer *http_server = static_cast<HttpServer*>(http_server_ptr);
HttpRequest *request;
// on the first call ptr is null
if (*ptr == NULL) {
request = new HttpRequest(url, method, version, connection);
if (!request)
return MHD_NO;
if (!request->Init()) {
delete request;
return MHD_NO;
}
*ptr = static_cast<void*>(request);
return MHD_YES;
}
request = static_cast<HttpRequest*>(*ptr);
if (request->InFlight())
// don't dispatch more than once
return MHD_YES;
if (request->Method() == MHD_HTTP_METHOD_GET) {
HttpResponse *response = new HttpResponse(connection);
request->SetInFlight();
return http_server->DispatchRequest(request, response);
} else if (request->Method() == MHD_HTTP_METHOD_POST) {
if (*upload_data_size != 0) {
request->ProcessPostData(upload_data, upload_data_size);
*upload_data_size = 0;
return MHD_YES;
}
request->SetInFlight();
HttpResponse *response = new HttpResponse(connection);
return http_server->DispatchRequest(request, response);
}
return MHD_NO;
}