summaryrefslogtreecommitdiffstats
path: root/src/network/access
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2022-04-12 14:01:55 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2022-04-21 23:53:15 +0200
commitf2637e1a77a5965a23e54c07587885f5a04ec877 (patch)
tree4564a5c63987750fb10da013b332aefe4a8825c7 /src/network/access
parente2a13299101d27800d3d1d88b91635e66d52d5c0 (diff)
QtNetwork: stop using QLatin1Char constructor for creating char literals
Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Change-Id: I121f87214b77aeab1dfd3e62dc5adaa6255cc0e0 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qhsts.cpp2
-rw-r--r--src/network/access/qhttpthreaddelegate.cpp2
-rw-r--r--src/network/access/qnetworkaccessfilebackend.cpp2
-rw-r--r--src/network/access/qnetworkcookie.cpp12
-rw-r--r--src/network/access/qnetworkcookiejar.cpp10
-rw-r--r--src/network/access/qnetworkdiskcache.cpp9
-rw-r--r--src/network/access/qnetworkreplyfileimpl.cpp2
7 files changed, 19 insertions, 20 deletions
diff --git a/src/network/access/qhsts.cpp b/src/network/access/qhsts.cpp
index 99c4c605dd..8befc0b8e7 100644
--- a/src/network/access/qhsts.cpp
+++ b/src/network/access/qhsts.cpp
@@ -210,7 +210,7 @@ bool QHstsCache::isKnownHost(const QUrl &url) const
}
}
- const int dot = nameToTest.fragment.indexOf(QLatin1Char('.'));
+ const qsizetype dot = nameToTest.fragment.indexOf(u'.');
if (dot == -1)
break;
diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp
index 9774e5b43e..80ad5dfd42 100644
--- a/src/network/access/qhttpthreaddelegate.cpp
+++ b/src/network/access/qhttpthreaddelegate.cpp
@@ -172,7 +172,7 @@ static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy, const QString &p
Q_UNUSED(proxy);
#endif
if (!peerVerifyName.isEmpty())
- result += QLatin1Char(':') + peerVerifyName;
+ result += u':' + peerVerifyName;
return "http-connection:" + std::move(result).toLatin1();
}
diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp
index b10013f67a..8f089bec3c 100644
--- a/src/network/access/qnetworkaccessfilebackend.cpp
+++ b/src/network/access/qnetworkaccessfilebackend.cpp
@@ -131,7 +131,7 @@ void QNetworkAccessFileBackend::open()
QString fileName = url.toLocalFile();
if (fileName.isEmpty()) {
if (url.scheme() == QLatin1String("qrc")) {
- fileName = QLatin1Char(':') + url.path();
+ fileName = u':' + url.path();
} else {
#if defined(Q_OS_ANDROID)
if (url.scheme() == QLatin1String("assets"))
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp
index ee85bbccb8..b9826fe1ed 100644
--- a/src/network/access/qnetworkcookie.cpp
+++ b/src/network/access/qnetworkcookie.cpp
@@ -541,7 +541,7 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const
}
if (!d->domain.isEmpty()) {
result += "; domain=";
- if (d->domain.startsWith(QLatin1Char('.'))) {
+ if (d->domain.startsWith(u'.')) {
result += '.';
result += QUrl::toAce(d->domain.mid(1));
} else {
@@ -1028,7 +1028,7 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt
if (!rawDomain.isEmpty()) {
QString maybeLeadingDot;
if (rawDomain.startsWith('.')) {
- maybeLeadingDot = QLatin1Char('.');
+ maybeLeadingDot = u'.';
rawDomain = rawDomain.mid(1);
}
@@ -1096,9 +1096,9 @@ void QNetworkCookie::normalize(const QUrl &url)
// don't do path checking. See QTBUG-5815
if (d->path.isEmpty()) {
QString pathAndFileName = url.path();
- QString defaultPath = pathAndFileName.left(pathAndFileName.lastIndexOf(QLatin1Char('/'))+1);
+ QString defaultPath = pathAndFileName.left(pathAndFileName.lastIndexOf(u'/') + 1);
if (defaultPath.isEmpty())
- defaultPath = QLatin1Char('/');
+ defaultPath = u'/';
d->path = defaultPath;
}
@@ -1108,12 +1108,12 @@ void QNetworkCookie::normalize(const QUrl &url)
QHostAddress hostAddress(d->domain);
if (hostAddress.protocol() != QAbstractSocket::IPv4Protocol
&& hostAddress.protocol() != QAbstractSocket::IPv6Protocol
- && !d->domain.startsWith(QLatin1Char('.'))) {
+ && !d->domain.startsWith(u'.')) {
// Ensure the domain starts with a dot if its field was not empty
// in the HTTP header. There are some servers that forget the
// leading dot and this is actually forbidden according to RFC 2109,
// but all browsers accept it anyway so we do that as well.
- d->domain.prepend(QLatin1Char('.'));
+ d->domain.prepend(u'.');
}
}
}
diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp
index 52da6553e4..de2449279a 100644
--- a/src/network/access/qnetworkcookiejar.cpp
+++ b/src/network/access/qnetworkcookiejar.cpp
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
static bool qIsEffectiveTLD(QStringView domain)
{
// provide minimal checking by not accepting cookies on real TLDs
- return !domain.contains(QLatin1Char('.'));
+ return !domain.contains(u'.');
}
QT_END_NAMESPACE
#endif
@@ -167,7 +167,7 @@ static inline bool isParentPath(const QString &path, const QString &reference)
static inline bool isParentDomain(const QString &domain, const QString &reference)
{
- if (!reference.startsWith(QLatin1Char('.')))
+ if (!reference.startsWith(u'.'))
return domain == reference;
return domain.endsWith(reference) || domain == QStringView{reference}.mid(1);
@@ -250,13 +250,13 @@ QList<QNetworkCookie> QNetworkCookieJar::cookiesForUrl(const QUrl &url) const
continue;
QString domain = it->domain();
- if (domain.startsWith(QLatin1Char('.'))) /// Qt6?: remove when compliant with RFC6265
+ if (domain.startsWith(u'.')) /// Qt6?: remove when compliant with RFC6265
domain = domain.mid(1);
#if QT_CONFIG(topleveldomain)
if (qIsEffectiveTLD(domain) && url.host() != domain)
continue;
#else
- if (!domain.contains(QLatin1Char('.')) && url.host() != domain)
+ if (!domain.contains(u'.') && url.host() != domain)
continue;
#endif // topleveldomain
@@ -356,7 +356,7 @@ bool QNetworkCookieJar::validateCookie(const QNetworkCookie &cookie, const QUrl
if (!isParentDomain(domain, host) && !isParentDomain(host, domain))
return false; // not accepted
- if (domain.startsWith(QLatin1Char('.')))
+ if (domain.startsWith(u'.'))
domain = domain.mid(1);
// We shouldn't reject if:
diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp
index 5f168be258..6abb92a8a0 100644
--- a/src/network/access/qnetworkdiskcache.cpp
+++ b/src/network/access/qnetworkdiskcache.cpp
@@ -148,10 +148,10 @@ void QNetworkDiskCache::setCacheDirectory(const QString &cacheDir)
d->cacheDirectory = cacheDir;
QDir dir(d->cacheDirectory);
d->cacheDirectory = dir.absolutePath();
- if (!d->cacheDirectory.endsWith(QLatin1Char('/')))
- d->cacheDirectory += QLatin1Char('/');
+ if (!d->cacheDirectory.endsWith(u'/'))
+ d->cacheDirectory += u'/';
- d->dataDirectory = d->cacheDirectory + DATA_DIR + QString::number(CACHE_VERSION) + QLatin1Char('/');
+ d->dataDirectory = d->cacheDirectory + DATA_DIR + QString::number(CACHE_VERSION) + u'/';
d->prepareLayout();
}
@@ -598,8 +598,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) + QLatin1Char('/')
- + QLatin1String(id) + CACHE_POSTFIX;
+ QString pathFragment = QString::number(code, 16) + u'/' + QLatin1String(id) + CACHE_POSTFIX;
return pathFragment;
}
diff --git a/src/network/access/qnetworkreplyfileimpl.cpp b/src/network/access/qnetworkreplyfileimpl.cpp
index 96b340756a..319325df09 100644
--- a/src/network/access/qnetworkreplyfileimpl.cpp
+++ b/src/network/access/qnetworkreplyfileimpl.cpp
@@ -105,7 +105,7 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
if (fileName.isEmpty()) {
const QString scheme = url.scheme();
if (scheme == QLatin1String("qrc")) {
- fileName = QLatin1Char(':') + url.path();
+ fileName = u':' + url.path();
} else {
#if defined(Q_OS_ANDROID)
if (scheme == QLatin1String("assets"))