本文整理汇总了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
}