diff options
| author | Tasuku Suzuki <tasuku.suzuki@qbc.io> | 2019-05-07 13:35:22 +0900 |
|---|---|---|
| committer | Tasuku Suzuki <tasuku.suzuki@qbc.io> | 2019-05-09 15:14:33 +0000 |
| commit | 26b4df2582eaeea3ea1adeef64311e67544c2dee (patch) | |
| tree | 8e288c56497fe8fc370ed374396caace79543cf8 /src/httpserver/qhttpserverrequest.cpp | |
| parent | 9f7bf6654b0dc4f981a7cb88f2dc588e0c8e65db (diff) | |
Change QString for headers in QHttpServerRequest to QByteArray
This is because QHttpServerResponder uses QByteArray for headers' key/
value.
Change-Id: I21b5af4d08e43ee58a1edc95b714c6da0ae10790
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Diffstat (limited to 'src/httpserver/qhttpserverrequest.cpp')
| -rw-r--r-- | src/httpserver/qhttpserverrequest.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/httpserver/qhttpserverrequest.cpp b/src/httpserver/qhttpserverrequest.cpp index b92024a..7500ede 100644 --- a/src/httpserver/qhttpserverrequest.cpp +++ b/src/httpserver/qhttpserverrequest.cpp @@ -83,7 +83,7 @@ QHttpServerRequestPrivate::QHttpServerRequestPrivate() httpParser.data = this; } -QString QHttpServerRequestPrivate::header(const QString &key) const +QByteArray QHttpServerRequestPrivate::header(const QByteArray &key) const { return headers.value(headerHash(key)).second; } @@ -111,7 +111,7 @@ bool QHttpServerRequestPrivate::parse(QIODevice *socket) return true; } -uint QHttpServerRequestPrivate::headerHash(const QString &key) const +uint QHttpServerRequestPrivate::headerHash(const QByteArray &key) const { return qHash(key.toLower(), headersSeed); } @@ -183,8 +183,8 @@ int QHttpServerRequestPrivate::onHeaderField(http_parser *httpParser, const char qCDebug(lc) << httpParser << QString::fromUtf8(at, int(length)); auto i = instance(httpParser); i->state = State::OnHeaders; - const auto key = QString::fromUtf8(at, int(length)); - i->headers.insert(i->headerHash(key), qMakePair(key, QString())); + const auto key = QByteArray(at, int(length)); + i->headers.insert(i->headerHash(key), qMakePair(key, QByteArray())); i->lastHeader = key; return 0; } @@ -195,9 +195,9 @@ int QHttpServerRequestPrivate::onHeaderValue(http_parser *httpParser, const char auto i = instance(httpParser); i->state = State::OnHeaders; Q_ASSERT(!i->lastHeader.isEmpty()); - const auto value = QString::fromUtf8(at, int(length)); + const auto value = QByteArray(at, int(length)); i->headers[i->headerHash(i->lastHeader)] = qMakePair(i->lastHeader, value); - if (i->lastHeader.compare(QStringLiteral("host"), Qt::CaseInsensitive) == 0) + if (i->lastHeader.compare(QByteArrayLiteral("host"), Qt::CaseInsensitive) == 0) parseUrl(at, length, true, &i->url); #if defined(QT_DEBUG) i->lastHeader.clear(); @@ -261,7 +261,7 @@ QHttpServerRequest::QHttpServerRequest(const QHttpServerRequest &other) : QHttpServerRequest::~QHttpServerRequest() {} -QString QHttpServerRequest::value(const QString &key) const +QByteArray QHttpServerRequest::value(const QByteArray &key) const { return d->headers.value(d->headerHash(key)).second; } |
