diff --git a/src/thttprequest.cpp b/src/thttprequest.cpp index 1c38db9f7..ddd5ba6bc 100644 --- a/src/thttprequest.cpp +++ b/src/thttprequest.cpp @@ -110,9 +110,9 @@ THttpRequest::THttpRequest(const QByteArray &header, const QString &filePath, co */ THttpRequest::~THttpRequest() { - if (bodyDevide) { - bodyDevide->close(); - delete bodyDevide; + if (bodyDevice) { + bodyDevice->close(); + delete bodyDevice; } } @@ -121,10 +121,10 @@ THttpRequest::~THttpRequest() */ THttpRequest &THttpRequest::operator=(const THttpRequest &other) { - if (bodyDevide) { - bodyDevide->close(); - delete bodyDevide; - bodyDevide = nullptr; + if (bodyDevice) { + bodyDevice->close(); + delete bodyDevice; + bodyDevice = nullptr; } d = other.d; @@ -170,19 +170,19 @@ Tf::HttpMethod THttpRequest::realMethod() const Tf::HttpMethod THttpRequest::getHttpMethodOverride() const { Tf::HttpMethod method; - QString str = d->header.rawHeader("X-HTTP-Method-Override").toLower(); + QString str = d->header.rawHeader(QByteArrayLiteral("X-HTTP-Method-Override")).toLower(); method = methodHash()->value(str, Tf::Invalid); if (method != Tf::Invalid) { return method; } - str = d->header.rawHeader("X-HTTP-Method").toLower(); + str = d->header.rawHeader(QByteArrayLiteral("X-HTTP-Method")).toLower(); method = methodHash()->value(str, Tf::Invalid); if (method != Tf::Invalid) { return method; } - str = d->header.rawHeader("X-METHOD-OVERRIDE").toLower(); + str = d->header.rawHeader(QByteArrayLiteral("X-METHOD-OVERRIDE")).toLower(); method = methodHash()->value(str, Tf::Invalid); return method; } @@ -193,7 +193,7 @@ Tf::HttpMethod THttpRequest::getHttpMethodOverride() const */ Tf::HttpMethod THttpRequest::queryItemMethod() const { - QString queryMethod = queryItemValue("_method"); + QString queryMethod = queryItemValue(QStringLiteral("_method")); return methodHash()->value(queryMethod, Tf::Invalid); } @@ -210,7 +210,7 @@ QString THttpRequest::parameter(const QString &name) const bool THttpRequest::hasItem(const QString &name, const QList> &items) { - const QRegExp rx(QRegExp::escape(name) + "(\\[[^\\[\\]]*\\]){0,2}"); + const QRegExp rx(QRegExp::escape(name) + QLatin1String("(\\[[^\\[\\]]*\\]){0,2}")); for (auto &p : items) { if (rx.exactMatch(p.first)) { @@ -289,7 +289,7 @@ QStringList THttpRequest::allQueryItemValues(const QString &name) const QStringList THttpRequest::queryItemList(const QString &key) const { QString k = key; - if (!k.endsWith("[]")) { + if (!k.endsWith(QLatin1String("[]"))) { k += QLatin1String("[]"); } return allQueryItemValues(k); @@ -385,7 +385,7 @@ QStringList THttpRequest::allFormItemValues(const QString &name) const QStringList THttpRequest::formItemList(const QString &key) const { QString k = key; - if (!k.endsWith("[]")) { + if (!k.endsWith(QLatin1String("[]"))) { k += QLatin1String("[]"); } return allFormItemValues(k); @@ -396,7 +396,7 @@ QVariantList THttpRequest::itemVariantList(const QString &key, const QListmultipartFormData = TMultipartFormData(body, boundary()); d->formItems = d->multipartFormData.postParameters; - } else if (ctype.startsWith("application/json", Qt::CaseInsensitive)) { + } else if (ctype.startsWith(QLatin1String("application/json"), Qt::CaseInsensitive)) { QJsonParseError error; d->jsonData = QJsonDocument::fromJson(body, &error); if (error.error != QJsonParseError::NoError) { tSystemWarn("Json data: %s\n error: %s\n at: %d", body.data(), qPrintable(error.errorString()), error.offset); } - } else if (ctype.startsWith("application/x-www-form-urlencoded", Qt::CaseInsensitive)) { + } else if (ctype.startsWith(QLatin1String("application/x-www-form-urlencoded"), Qt::CaseInsensitive)) { if (!body.isEmpty()) { const QList formdata = body.split('&'); for (auto &frm : formdata) { @@ -541,13 +541,13 @@ void THttpRequest::parseBody(const QByteArray &body, const THttpRequestHeader &h QByteArray THttpRequest::boundary() const { QByteArray boundary; - QString contentType = d->header.rawHeader("content-type").trimmed(); + QString contentType = d->header.rawHeader(QByteArrayLiteral("content-type")).trimmed(); - if (contentType.startsWith("multipart/form-data", Qt::CaseInsensitive)) { + if (contentType.startsWith(QLatin1String("multipart/form-data"), Qt::CaseInsensitive)) { const QStringList lst = contentType.split(QChar(';'), QString::SkipEmptyParts, Qt::CaseSensitive); for (auto &bnd : lst) { QString string = bnd.trimmed(); - if (string.startsWith("boundary=", Qt::CaseInsensitive)) { + if (string.startsWith(QLatin1String("boundary="), Qt::CaseInsensitive)) { boundary = string.mid(9).toLatin1(); // strip optional surrounding quotes (RFC 2046 and 7578) if (boundary.startsWith('"') && boundary.endsWith('"')) { @@ -613,14 +613,14 @@ QList THttpRequest::generate(const QByteArray &byteArray, const QH QIODevice *THttpRequest::rawBody() { - if (! bodyDevide) { + if (! bodyDevice) { if (! d->multipartFormData.bodyFile.isEmpty()) { - bodyDevide = new QFile(d->multipartFormData.bodyFile); + bodyDevice = new QFile(d->multipartFormData.bodyFile); } else { - bodyDevide = new QBuffer(&d->bodyArray); + bodyDevice = new QBuffer(&d->bodyArray); } } - return bodyDevide; + return bodyDevice; } diff --git a/src/thttprequest.h b/src/thttprequest.h index b07068d61..030a56c6d 100644 --- a/src/thttprequest.h +++ b/src/thttprequest.h @@ -93,7 +93,7 @@ class T_CORE_EXPORT THttpRequest void parseBody(const QByteArray &body, const THttpRequestHeader &header); QSharedDataPointer d; - QIODevice *bodyDevide {nullptr}; + QIODevice *bodyDevice {nullptr}; friend class TMultipartFormData; };