diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-05-13 21:53:07 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-06-22 20:12:41 +0000 |
commit | cad7100fda1b27ba56c4d9efc6bceba62859dfbc (patch) | |
tree | 942ff836a94aab364ae8c408dcfa44d8808c8134 /src/network/access/qhttp2protocolhandler.cpp | |
parent | c699daeceb4448c4545a67ffdba27bcb3b994114 (diff) |
QByteArray: add compare() with case sensitivity options
Need to do the same for startsWith() and endsWith(). indexOf() is a lot
harder.
[ChangeLog][QtCore][QByteArray] Added compare(), which takes
Qt::CaseSensitivity as one of the parameters. This function is more
efficient than using toLower() or toUpper() and then comparing.
Change-Id: Ib48364abee9f464c96c6fffd152e69bde4194df7
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network/access/qhttp2protocolhandler.cpp')
-rw-r--r-- | src/network/access/qhttp2protocolhandler.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp index c207d6e240..df7f87efd4 100644 --- a/src/network/access/qhttp2protocolhandler.cpp +++ b/src/network/access/qhttp2protocolhandler.cpp @@ -97,16 +97,18 @@ HPack::HttpHeader build_headers(const QHttpNetworkRequest &request, quint32 maxH if (size.second > maxHeaderListSize) break; - QByteArray key(field.first.toLower()); - if (key == "connection" || key == "host" || key == "keep-alive" - || key == "proxy-connection" || key == "transfer-encoding") + if (field.first.compare("connection", Qt::CaseInsensitive) == 0 || + field.first.compare("host", Qt::CaseInsensitive) == 0 || + field.first.compare("keep-alive", Qt::CaseInsensitive) == 0 || + field.first.compare("proxy-connection", Qt::CaseInsensitive) == 0 || + field.first.compare("transfer-encoding", Qt::CaseInsensitive) == 0) continue; // Those headers are not valid (section 3.2.1) - from QSpdyProtocolHandler // TODO: verify with specs, which fields are valid to send .... // toLower - 8.1.2 .... "header field names MUST be converted to lowercase prior // to their encoding in HTTP/2. // A request or response containing uppercase header field names // MUST be treated as malformed (Section 8.1.2.6)". - header.push_back(HeaderField(key, field.second)); + header.push_back(HeaderField(field.first.toLower(), field.second)); } return header; @@ -1404,8 +1406,9 @@ bool QHttp2ProtocolHandler::tryReserveStream(const Http2::Frame &pushPromiseFram return false; } - const auto method = pseudoHeaders[":method"].toLower(); - if (method != "get" && method != "head") + const QByteArray method = pseudoHeaders[":method"]; + if (method.compare("get", Qt::CaseInsensitive) != 0 && + method.compare("head", Qt::CaseInsensitive) != 0) return false; QUrl url; |