本文整理汇总了C++中HTTPHeaderMap::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPHeaderMap::isEmpty方法的具体用法?C++ HTTPHeaderMap::isEmpty怎么用?C++ HTTPHeaderMap::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPHeaderMap
的用法示例。
在下文中一共展示了HTTPHeaderMap::isEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startHttp
bool ResourceHandle::startHttp(String urlString)
{
if (!session) {
session = soup_session_async_new();
soup_session_add_feature(session, SOUP_SESSION_FEATURE(getCookieJar()));
const char* soup_debug = g_getenv("WEBKIT_SOUP_LOGGING");
if (soup_debug) {
int soup_debug_level = atoi(soup_debug);
SoupLogger* logger = soup_logger_new(static_cast<SoupLoggerLogLevel>(soup_debug_level), -1);
soup_logger_attach(logger, session);
g_object_unref(logger);
}
}
SoupMessage* msg;
msg = soup_message_new(request().httpMethod().utf8().data(), urlString.utf8().data());
g_signal_connect(msg, "restarted", G_CALLBACK(restartedCallback), this);
g_signal_connect(msg, "got-headers", G_CALLBACK(gotHeadersCallback), this);
g_signal_connect(msg, "got-chunk", G_CALLBACK(gotChunkCallback), this);
HTTPHeaderMap customHeaders = d->m_request.httpHeaderFields();
if (!customHeaders.isEmpty()) {
HTTPHeaderMap::const_iterator end = customHeaders.end();
for (HTTPHeaderMap::const_iterator it = customHeaders.begin(); it != end; ++it)
soup_message_headers_append(msg->request_headers, it->first.utf8().data(), it->second.utf8().data());
}
FormData* httpBody = d->m_request.httpBody();
if (httpBody && !httpBody->isEmpty()) {
// Making a copy of the request body isn't the most efficient way to
// serialize it, but by far the most simple. Dealing with individual
// FormData elements and shared buffers should be more memory
// efficient.
//
// This possibly isn't handling file uploads/attachments, for which
// shared buffers or streaming should definitely be used.
Vector<char> body;
httpBody->flatten(body);
soup_message_set_request(msg, d->m_request.httpContentType().utf8().data(),
SOUP_MEMORY_COPY, body.data(), body.size());
}
d->m_msg = static_cast<SoupMessage*>(g_object_ref(msg));
soup_session_queue_message(session, d->m_msg, finishedCallback, this);
return true;
}
示例2: toSoupMessage
SoupMessage* ResourceRequest::toSoupMessage() const
{
SoupMessage* soupMessage = soup_message_new(httpMethod().utf8().data(), url().string().utf8().data());
if (!soupMessage)
return 0;
HTTPHeaderMap headers = httpHeaderFields();
SoupMessageHeaders* soupHeaders = soupMessage->request_headers;
if (!headers.isEmpty()) {
HTTPHeaderMap::const_iterator end = headers.end();
for (HTTPHeaderMap::const_iterator it = headers.begin(); it != end; ++it)
soup_message_headers_append(soupHeaders, it->first.string().utf8().data(), it->second.utf8().data());
}
// Body data is only handled at ResourceHandleSoup::startHttp for
// now; this is because this may not be a good place to go
// openning and mmapping files. We should maybe revisit this.
return soupMessage;
}
示例3: toSoupMessage
SoupMessage* ResourceResponse::toSoupMessage() const
{
// This GET here is just because SoupMessage wants it, we dn't really know.
SoupMessage* soupMessage = soup_message_new("GET", url().string().utf8().data());
if (!soupMessage)
return 0;
soupMessage->status_code = httpStatusCode();
HTTPHeaderMap headers = httpHeaderFields();
SoupMessageHeaders* soupHeaders = soupMessage->response_headers;
if (!headers.isEmpty()) {
HTTPHeaderMap::const_iterator end = headers.end();
for (HTTPHeaderMap::const_iterator it = headers.begin(); it != end; ++it)
soup_message_headers_append(soupHeaders, it->first.string().utf8().data(), it->second.utf8().data());
}
// Body data is not in the message.
return soupMessage;
}