QtNetwork: replace remaining uses of QLatin1String by QLatin1StringView
Task-number: QTBUG-98434 Change-Id: I0bb9d534ee42ccbf7d353e251ef58901a86923b4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
46d6cc47cf
commit
301f0a6fb0
@ -151,7 +151,7 @@ QUrl urlkey_from_request(const QHttpNetworkRequest &request)
|
||||
|
||||
url.setScheme(request.url().scheme());
|
||||
url.setAuthority(request.url().authority(QUrl::FullyEncoded | QUrl::RemoveUserInfo));
|
||||
url.setPath(QLatin1String(request.uri(false)));
|
||||
url.setPath(QLatin1StringView(request.uri(false)));
|
||||
|
||||
return url;
|
||||
}
|
||||
@ -1537,9 +1537,9 @@ bool QHttp2ProtocolHandler::tryReserveStream(const Http2::Frame &pushPromiseFram
|
||||
return false;
|
||||
|
||||
QUrl url;
|
||||
url.setScheme(QLatin1String(pseudoHeaders[":scheme"]));
|
||||
url.setAuthority(QLatin1String(pseudoHeaders[":authority"]));
|
||||
url.setPath(QLatin1String(pseudoHeaders[":path"]));
|
||||
url.setScheme(QLatin1StringView(pseudoHeaders[":scheme"]));
|
||||
url.setAuthority(QLatin1StringView(pseudoHeaders[":authority"]));
|
||||
url.setPath(QLatin1StringView(pseudoHeaders[":path"]));
|
||||
|
||||
if (!url.isValid())
|
||||
return false;
|
||||
@ -1636,7 +1636,7 @@ void QHttp2ProtocolHandler::connectionError(Http2::Http2Error errorCode,
|
||||
m_channel->emitFinishedWithError(error, message);
|
||||
|
||||
for (auto &stream: activeStreams)
|
||||
finishStreamWithError(stream, error, QLatin1String(message));
|
||||
finishStreamWithError(stream, error, QLatin1StringView(message));
|
||||
|
||||
closeSession();
|
||||
}
|
||||
|
@ -522,8 +522,8 @@ void QHttpThreadDelegate::finishedSlot()
|
||||
|
||||
if (httpReply->statusCode() >= 400) {
|
||||
// it's an error reply
|
||||
QString msg = QLatin1String(QT_TRANSLATE_NOOP("QNetworkReply",
|
||||
"Error transferring %1 - server replied: %2"));
|
||||
QString msg = QLatin1StringView(QT_TRANSLATE_NOOP("QNetworkReply",
|
||||
"Error transferring %1 - server replied: %2"));
|
||||
msg = msg.arg(httpRequest.url().toString(), httpReply->reasonPhrase());
|
||||
emit error(statusCodeFromHttp(httpReply->statusCode(), httpRequest.url()), msg);
|
||||
}
|
||||
@ -548,8 +548,8 @@ void QHttpThreadDelegate::synchronousFinishedSlot()
|
||||
#endif
|
||||
if (httpReply->statusCode() >= 400) {
|
||||
// it's an error reply
|
||||
QString msg = QLatin1String(QT_TRANSLATE_NOOP("QNetworkReply",
|
||||
"Error transferring %1 - server replied: %2"));
|
||||
QString msg = QLatin1StringView(QT_TRANSLATE_NOOP("QNetworkReply",
|
||||
"Error transferring %1 - server replied: %2"));
|
||||
incomingErrorDetail = msg.arg(httpRequest.url().toString(), httpReply->reasonPhrase());
|
||||
incomingErrorCode = statusCodeFromHttp(httpReply->statusCode(), httpRequest.url());
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ QString QNetworkDiskCachePrivate::uniqueFileName(const QUrl &url)
|
||||
const QByteArray id = QByteArray::number(*(qlonglong*)hash.data(), 36).left(8);
|
||||
// generates <one-char subdir>/<8-char filname.d>
|
||||
uint code = (uint)id.at(id.length()-1) % 16;
|
||||
QString pathFragment = QString::number(code, 16) + u'/' + QLatin1String(id) + CACHE_POSTFIX;
|
||||
QString pathFragment = QString::number(code, 16) + u'/' + QLatin1StringView(id) + CACHE_POSTFIX;
|
||||
|
||||
return pathFragment;
|
||||
}
|
||||
|
@ -1316,7 +1316,7 @@ void QNetworkReplyHttpImplPrivate::checkForRedirect(const int statusCode)
|
||||
QByteArray header = q->rawHeader("location");
|
||||
QUrl url = QUrl(QString::fromUtf8(header));
|
||||
if (!url.isValid())
|
||||
url = QUrl(QLatin1String(header));
|
||||
url = QUrl(QLatin1StringView(header));
|
||||
q->setAttribute(QNetworkRequest::RedirectionTargetAttribute, url);
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class QHostInfoPrivate
|
||||
public:
|
||||
inline QHostInfoPrivate()
|
||||
: err(QHostInfo::NoError),
|
||||
errorStr(QLatin1String(QT_TRANSLATE_NOOP("QHostInfo", "Unknown error"))),
|
||||
errorStr(QLatin1StringView(QT_TRANSLATE_NOOP("QHostInfo", "Unknown error"))),
|
||||
lookupId(0)
|
||||
{
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ static QNetworkInterfacePrivate *findInterface(int socket, QList<QNetworkInterfa
|
||||
// Search by name
|
||||
QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin();
|
||||
for ( ; if_it != interfaces.end(); ++if_it)
|
||||
if ((*if_it)->name == QLatin1String(req.ifr_name)) {
|
||||
if ((*if_it)->name == QLatin1StringView(req.ifr_name)) {
|
||||
// existing interface
|
||||
iface = *if_it;
|
||||
break;
|
||||
@ -627,7 +627,7 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
|
||||
interfaces = createInterfaces(interfaceListing);
|
||||
for (ifaddrs *ptr = interfaceListing; ptr; ptr = ptr->ifa_next) {
|
||||
// Find the interface
|
||||
QLatin1String name(ptr->ifa_name);
|
||||
QLatin1StringView name(ptr->ifa_name);
|
||||
QNetworkInterfacePrivate *iface = nullptr;
|
||||
QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin();
|
||||
for ( ; if_it != interfaces.end(); ++if_it)
|
||||
|
@ -64,7 +64,7 @@ static bool ignoreProxyFor(const QNetworkProxyQuery &query)
|
||||
const QList<QByteArray> noProxyTokens = noProxy.split(',');
|
||||
|
||||
for (const QByteArray &rawToken : noProxyTokens) {
|
||||
auto token = QLatin1String(rawToken).trimmed();
|
||||
auto token = QLatin1StringView(rawToken).trimmed();
|
||||
|
||||
// Since we use suffix matching, "*" is our 'default' behaviour
|
||||
if (token.startsWith(u'*'))
|
||||
|
@ -73,7 +73,7 @@ QSocketEngineHandler::~QSocketEngineHandler()
|
||||
QAbstractSocketEnginePrivate::QAbstractSocketEnginePrivate()
|
||||
: socketError(QAbstractSocket::UnknownSocketError)
|
||||
, hasSetSocketError(false)
|
||||
, socketErrorString(QLatin1String(QT_TRANSLATE_NOOP(QSocketLayer, "Unknown error")))
|
||||
, socketErrorString(QLatin1StringView(QT_TRANSLATE_NOOP(QSocketLayer, "Unknown error")))
|
||||
, socketState(QAbstractSocket::UnconnectedState)
|
||||
, socketType(QAbstractSocket::UnknownSocketType)
|
||||
, socketProtocol(QAbstractSocket::UnknownNetworkLayerProtocol)
|
||||
|
@ -1387,7 +1387,7 @@ bool QSocks5SocketEngine::bind(const QHostAddress &addr, quint16 port)
|
||||
|
||||
// binding timed out
|
||||
setError(QAbstractSocket::SocketTimeoutError,
|
||||
QLatin1String(QT_TRANSLATE_NOOP("QSocks5SocketEngine", "Network operation timed out")));
|
||||
QLatin1StringView(QT_TRANSLATE_NOOP("QSocks5SocketEngine", "Network operation timed out")));
|
||||
|
||||
///### delete d->udpSocket;
|
||||
///### d->udpSocket = 0;
|
||||
|
@ -3061,7 +3061,7 @@ bool QSslSocketPrivate::isMatchingHostname(const QString &cn, const QString &hos
|
||||
|
||||
// Check this is a wildcard cert, if not then just compare the strings
|
||||
if (wildcard < 0)
|
||||
return QLatin1String(QUrl::toAce(cn)) == hostname;
|
||||
return QLatin1StringView(QUrl::toAce(cn)) == hostname;
|
||||
|
||||
qsizetype firstCnDot = cn.indexOf(u'.');
|
||||
qsizetype secondCnDot = cn.indexOf(u'.', firstCnDot+1);
|
||||
@ -3090,7 +3090,7 @@ bool QSslSocketPrivate::isMatchingHostname(const QString &cn, const QString &hos
|
||||
// Check characters following first . match
|
||||
qsizetype hnDot = hostname.indexOf(u'.');
|
||||
if (QStringView{hostname}.mid(hnDot + 1) != QStringView{cn}.mid(firstCnDot + 1)
|
||||
&& QStringView{hostname}.mid(hnDot + 1) != QLatin1String(QUrl::toAce(cn.mid(firstCnDot + 1)))) {
|
||||
&& QStringView{hostname}.mid(hnDot + 1) != QLatin1StringView(QUrl::toAce(cn.mid(firstCnDot + 1)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -653,7 +653,7 @@ bool DtlsState::initTls(QDtlsBasePrivate *dtlsBase)
|
||||
static QString msgFunctionFailed(const char *function)
|
||||
{
|
||||
//: %1: Some function
|
||||
return QDtls::tr("%1 failed").arg(QLatin1String(function));
|
||||
return QDtls::tr("%1 failed").arg(QLatin1StringView(function));
|
||||
}
|
||||
|
||||
bool DtlsState::initCtxAndConnection(QDtlsBasePrivate *dtlsBase)
|
||||
|
@ -647,7 +647,7 @@ static QStringList libraryPathList()
|
||||
}
|
||||
|
||||
Q_NEVER_INLINE
|
||||
static QStringList findAllLibs(QLatin1String filter)
|
||||
static QStringList findAllLibs(QLatin1StringView filter)
|
||||
{
|
||||
const QStringList paths = libraryPathList();
|
||||
QStringList found;
|
||||
@ -682,7 +682,7 @@ struct LoadedOpenSsl {
|
||||
std::unique_ptr<QSystemLibrary> ssl, crypto;
|
||||
};
|
||||
|
||||
static bool tryToLoadOpenSslWin32Library(QLatin1String ssleay32LibName, QLatin1String libeay32LibName, LoadedOpenSsl &result)
|
||||
static bool tryToLoadOpenSslWin32Library(QLatin1StringView ssleay32LibName, QLatin1StringView libeay32LibName, LoadedOpenSsl &result)
|
||||
{
|
||||
auto ssleay32 = std::make_unique<QSystemLibrary>(ssleay32LibName);
|
||||
if (!ssleay32->load(false)) {
|
||||
|
@ -85,7 +85,7 @@ QSsl::AlertLevel tlsAlertLevel(int value)
|
||||
|
||||
QString tlsAlertDescription(int value)
|
||||
{
|
||||
QString description = QLatin1String(q_SSL_alert_desc_string_long(value));
|
||||
QString description = QLatin1StringView(q_SSL_alert_desc_string_long(value));
|
||||
if (!description.size())
|
||||
description = "no description provided"_L1;
|
||||
return description;
|
||||
|
@ -230,7 +230,7 @@ void QTlsBackendOpenSSL::ensureCiphersAndCertsLoaded() const
|
||||
QStringList symLinkFilter;
|
||||
symLinkFilter << "[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9]"_L1;
|
||||
for (const auto &dir : dirs) {
|
||||
QDirIterator iterator(QLatin1String(dir), symLinkFilter, QDir::Files);
|
||||
QDirIterator iterator(QLatin1StringView(dir), symLinkFilter, QDir::Files);
|
||||
if (iterator.hasNext()) {
|
||||
QSslSocketPrivate::setRootCertOnDemandLoadingSupported(true);
|
||||
break;
|
||||
@ -414,7 +414,7 @@ QList<QSslCertificate> systemCaCertificates()
|
||||
QDir currentDir;
|
||||
currentDir.setNameFilters(QStringList{QStringLiteral("*.pem"), QStringLiteral("*.crt")});
|
||||
for (const auto &directory : directories) {
|
||||
currentDir.setPath(QLatin1String(directory));
|
||||
currentDir.setPath(QLatin1StringView(directory));
|
||||
QDirIterator it(currentDir);
|
||||
while (it.hasNext()) {
|
||||
// use canonical path here to not load the same certificate twice if symlinked
|
||||
|
@ -119,7 +119,7 @@ EphemeralSecKeychain::EphemeralSecKeychain()
|
||||
Q_ASSERT(uuidAsByteArray.size() > 2);
|
||||
Q_ASSERT(uuidAsByteArray.startsWith('{'));
|
||||
Q_ASSERT(uuidAsByteArray.endsWith('}'));
|
||||
const auto uuidAsString = QLatin1String(uuidAsByteArray.data(), uuidAsByteArray.size()).mid(1, uuidAsByteArray.size() - 2);
|
||||
const auto uuidAsString = QLatin1StringView(uuidAsByteArray.data(), uuidAsByteArray.size()).mid(1, uuidAsByteArray.size() - 2);
|
||||
|
||||
const QString keychainName
|
||||
= QDir::tempPath() + QDir::separator() + uuidAsString + ".keychain"_L1;
|
||||
|
Loading…
Reference in New Issue
Block a user