test: migrate QNetworkReply test to QRegularExpression
This is part of the migration of qtbase from QRexExp to QRegularExpression. Task-number: QTBUG-72587 Change-Id: Ibdd3f63d9069c3f01dfe8431bcc64bde4f2aa569 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
605dc42a0f
commit
16cc3ea585
@ -109,8 +109,8 @@ public:
|
|||||||
static bool compareReplyFtp(QByteArray const& actual)
|
static bool compareReplyFtp(QByteArray const& actual)
|
||||||
{
|
{
|
||||||
// output would be e.g. "220 (vsFTPd 2.3.5)\r\n221 Goodbye.\r\n"
|
// output would be e.g. "220 (vsFTPd 2.3.5)\r\n221 Goodbye.\r\n"
|
||||||
QRegExp ftpVersion(QStringLiteral("220 \\(vsFTPd \\d+\\.\\d+.\\d+\\)\\r\\n221 Goodbye.\\r\\n"));
|
QRegularExpression ftpVersion(QRegularExpression::anchoredPattern(QStringLiteral("220 \\(vsFTPd \\d+\\.\\d+.\\d+\\)\\r\\n221 Goodbye.\\r\\n")));
|
||||||
return ftpVersion.exactMatch(actual);
|
return ftpVersion.match(actual).hasMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool hasIPv6()
|
static bool hasIPv6()
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
#include <QtCore/QEventLoop>
|
#include <QtCore/QEventLoop>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtCore/QRandomGenerator>
|
#include <QtCore/QRandomGenerator>
|
||||||
|
#include <QtCore/QRegularExpression>
|
||||||
|
#include <QtCore/QRegularExpressionMatch>
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
#include <QtCore/QScopedPointer>
|
#include <QtCore/QScopedPointer>
|
||||||
#include <QtCore/QTemporaryFile>
|
#include <QtCore/QTemporaryFile>
|
||||||
@ -7917,9 +7919,10 @@ void tst_QNetworkReply::synchronousAuthenticationCache()
|
|||||||
"Content-Type: text/plain\r\n"
|
"Content-Type: text/plain\r\n"
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"auth";
|
"auth";
|
||||||
QRegExp rx("Authorization: Basic ([^\r\n]*)\r\n");
|
QRegularExpression rx("Authorization: Basic ([^\r\n]*)\r\n");
|
||||||
if (rx.indexIn(receivedData) > 0) {
|
QRegularExpressionMatch match = rx.match(receivedData);
|
||||||
if (QByteArray::fromBase64(rx.cap(1).toLatin1()) == "login:password") {
|
if (match.hasMatch()) {
|
||||||
|
if (QByteArray::fromBase64(match.captured(1).toLatin1()) == "login:password") {
|
||||||
dataToTransmit =
|
dataToTransmit =
|
||||||
"HTTP/1.0 200 OK\r\n"
|
"HTTP/1.0 200 OK\r\n"
|
||||||
"Content-Type: text/plain\r\n"
|
"Content-Type: text/plain\r\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user