本文整理匯總了C++中wtf::String::lower方法的典型用法代碼示例。如果您正苦於以下問題:C++ String::lower方法的具體用法?C++ String::lower怎麽用?C++ String::lower使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wtf::String
的用法示例。
在下文中一共展示了String::lower方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: sendResponseIfNeeded
void QNetworkReplyHandler::sendResponseIfNeeded()
{
ASSERT(m_replyWrapper && m_replyWrapper->reply() && !wasAborted());
if (m_replyWrapper->reply()->error() && m_replyWrapper->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).isNull())
return;
ResourceHandleClient* client = m_resourceHandle->client();
if (!client)
return;
WTF::String mimeType = m_replyWrapper->mimeType();
if (mimeType.isEmpty()) {
// let's try to guess from the extension
mimeType = MIMETypeRegistry::getMIMETypeForPath(m_replyWrapper->reply()->url().path());
}
KURL url(m_replyWrapper->reply()->url());
ResourceResponse response(url, mimeType.lower(),
m_replyWrapper->reply()->header(QNetworkRequest::ContentLengthHeader).toLongLong(),
m_replyWrapper->encoding(), String());
if (url.isLocalFile()) {
client->didReceiveResponse(m_resourceHandle, response);
return;
}
// The status code is equal to 0 for protocols not in the HTTP family.
int statusCode = m_replyWrapper->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (url.protocolIsInHTTPFamily()) {
String suggestedFilename = filenameFromHTTPContentDisposition(QString::fromLatin1(m_replyWrapper->reply()->rawHeader("Content-Disposition")));
if (!suggestedFilename.isEmpty())
response.setSuggestedFilename(suggestedFilename);
else {
Vector<String> extensions = MIMETypeRegistry::getExtensionsForMIMEType(mimeType);
if (extensions.isEmpty())
response.setSuggestedFilename(url.lastPathComponent());
else {
// If the suffix doesn't match the MIME type, correct the suffix.
QString filename = url.lastPathComponent();
const String suffix = QMimeDatabase().suffixForFileName(filename);
if (!extensions.contains(suffix)) {
filename.chop(suffix.length());
filename += MIMETypeRegistry::getPreferredExtensionForMIMEType(mimeType);
}
response.setSuggestedFilename(filename);
}
}
response.setHTTPStatusCode(statusCode);
response.setHTTPStatusText(m_replyWrapper->reply()->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray().constData());
// Add remaining headers.
foreach (const QNetworkReply::RawHeaderPair& pair, m_replyWrapper->reply()->rawHeaderPairs())
response.setHTTPHeaderField(QString::fromLatin1(pair.first), QString::fromLatin1(pair.second));
}
示例2: sendResponseIfNeeded
void QNetworkReplyHandler::sendResponseIfNeeded()
{
m_shouldSendResponse = (m_loadMode != LoadNormal);
if (m_shouldSendResponse)
return;
if (m_reply->error() && !ignoreHttpError(m_reply, m_responseDataSent))
return;
if (m_responseSent || !m_resourceHandle)
return;
m_responseSent = true;
ResourceHandleClient* client = m_resourceHandle->client();
if (!client)
return;
WTF::String contentType = m_reply->header(QNetworkRequest::ContentTypeHeader).toString();
WTF::String encoding = extractCharsetFromMediaType(contentType);
WTF::String mimeType = extractMIMETypeFromMediaType(contentType);
if (mimeType.isEmpty()) {
// let's try to guess from the extension
QString extension = m_reply->url().path();
int index = extension.lastIndexOf(QLatin1Char('.'));
if (index > 0) {
extension = extension.mid(index + 1);
mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension);
}
}
KURL url(m_reply->url());
ResourceResponse response(url, mimeType.lower(),
m_reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(),
encoding, String());
if (url.isLocalFile()) {
client->didReceiveResponse(m_resourceHandle, response);
return;
}
// The status code is equal to 0 for protocols not in the HTTP family.
int statusCode = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (url.protocolInHTTPFamily()) {
String suggestedFilename = filenameFromHTTPContentDisposition(QString::fromAscii(m_reply->rawHeader("Content-Disposition")));
if (!suggestedFilename.isEmpty())
response.setSuggestedFilename(suggestedFilename);
else
response.setSuggestedFilename(url.lastPathComponent());
response.setHTTPStatusCode(statusCode);
response.setHTTPStatusText(m_reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray().constData());
// Add remaining headers.
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
foreach (const QNetworkReply::RawHeaderPair& pair, m_reply->rawHeaderPairs()) {
response.setHTTPHeaderField(QString::fromAscii(pair.first), QString::fromAscii(pair.second));
}
#else
foreach (const QByteArray& headerName, m_reply->rawHeaderList()) {
response.setHTTPHeaderField(QString::fromAscii(headerName), QString::fromAscii(m_reply->rawHeader(headerName)));
}
#endif
}