Commit Graph

637 Commits

Author SHA1 Message Date
Mårten Nordheim
78c5ca4c85 Update the public suffix list
Pick-to: 6.5
Task-number: QTBUG-110333
Change-Id: I741feee3a19d0a104496f543d35a1f311a7228d6
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-02-03 12:56:59 +01:00
Ahmad Samir
2ed4e5d37d Fix two compiler warnings
Comparing singed/usigned ints.
Use override keyword.

Change-Id: I03d2c4359e0600360ebcfece593a3b125e5c9c53
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-05 21:01:22 +02:00
Edward Welbourne
2f440169c0 Adapt to QTimeZone replacing Qt::TimeSpec usage
In the process actually handle all time-spec cases in various places
that only handled UTC or LocalTime, or at least note that they don't
where that's not practical. Also tidy up header ordering and ensure
QDateTime's header is included wherever it's used, while adding the
include for QTimeZone where needed.

Task-number: QTBUG-108199
Change-Id: Ic1a5cdf0aaf737bf1396aa8ac58ce2004cef7e19
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-10 06:39:44 +01:00
Markus Goetz
be05bb749e QNetworkAccessManager: Configurable number of HTTP1 TCP connections
Introduces new class QHttp1Configuration.

[ChangeLog][QtNetwork][QHttp1Configuration] New class.

Fixes: QTBUG-25280
Fixes: QTBUG-108215
Change-Id: Ide6cee23946e5001befb8fab34edf10b8a66e02b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-09 02:40:12 +00:00
Markus Goetz
9329e4e8c7 tst_QNetworkReply: check whether we actually use six TCP connections in HTTP/1
Pick-to: 6.4 6.2
Task-number: QTBUG-25280
Task-number: QTBUG-108215
Change-Id: I5f94866e30f08465943922e3dee5150f37054225
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-12-06 07:02:53 +01:00
Fabian Kosmale
090394ab6f tst_qdecompresshelper: Disable big data tests under ASAN
They are already slow without ASAN, and risk running into timeouts with
ASAN enabled.

Change-Id: I427b990066d8ffa838ea90a318176fbcba400852
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-30 03:50:37 +00:00
Marc Mutz
1c6bf3e09e Port from container::count() and length() to size() - V5
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:

    const std::string o = "object";

    auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };

    auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
        auto exprOfDeclaredType = [&](auto decl) {
            return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
        };
        return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
    };

    auto renameMethod = [&] (ArrayRef<StringRef> classes,
                            StringRef from, StringRef to) {
        return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
                            callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
                        changeTo(cat(access(o, cat(to)), "()")),
                        cat("use '", to, "' instead of '", from, "'"));
    };

    renameMethod(<classes>, "count", "size");
    renameMethod(<classes>, "length", "size");

except that the on() matcher has been replaced by one that doesn't
ignoreParens().

a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'.

Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache,
to avoid porting calls that explicitly test count().

Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-11-03 14:59:24 +01:00
Marc Mutz
df9d882d41 Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:

  auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
  makeRule(cxxMemberCallExpr(on(QtContainerClass),
                             callee(cxxMethodDecl(hasAnyName({"count", "length"),
                                                  parameterCountIs(0))))),
           changeTo(cat(access(o, cat("size"), "()"))),
           cat("use 'size()' instead of 'count()/length()'"))

a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.

<classes> are:

    // sequential:
    "QByteArray",
    "QList",
    "QQueue",
    "QStack",
    "QString",
    "QVarLengthArray",
    "QVector",
    // associative:
    "QHash",
    "QMultiHash",
    "QMap",
    "QMultiMap",
    "QSet",
    // Qt has no QMultiSet

Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-10-04 07:40:08 +02:00
Mårten Nordheim
1fa0e86995 QNetworkReply: honor legacy behavior of setting Accept-Encoding
And don't decompress the data

Pick-to: 6.4
Fixes: QTBUG-106689
Change-Id: I93a96be8178e24ff0b0bb8647276828161445cf5
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-09-22 15:34:51 +00:00
Mårten Nordheim
68f641095c QNetworkReplyFileImpl: Don't emit 'finished' in the ctor
Pick-to: 5.15 6.2 6.4
Fixes: QTBUG-105618
Change-Id: I3bd36fbd5818d54088098e750643c3e2de30496e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-09-16 17:02:06 +02:00
Mårten Nordheim
b31d902913 Http: Don't clear (de)compressed data on error
Some errors, such as 404, may still present useful data. As opposed to
errors such as 'RemoteDisconnected'. So, just keep the data around until
the reply is deleted.

Pick-to: 6.4
Fixes: QTBUG-106573
Change-Id: I6c86b5a55a45f837ea9b42559d88cd3e0ac2fa5c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-09-14 19:53:49 +02:00
Mårten Nordheim
9e12ea37ea tst_QNetworkreply: fix a path to test-data
For some reason it fails on Ubuntu 22.04, but it's anyway
not following the trend the rest of the file uses, so just
assume it's the code at fault and fix it.

Thanks to Liang Qi for debugging this!

Pick-to: 6.4
Fixes: QTBUG-106016
Change-Id: I9d0563a081827eaa037d61643f0ea46301e11493
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-09-13 16:00:44 +00:00
Mårten Nordheim
5387b88aa9 QNetworkReply: Fix missing final emission of readyRead
If we receive compressed data we will decompress it as it comes in,
in some cases the final byte we receive doesn't actually contribute
to the final output. If this byte is handled by itself then, when
combined with QNetworkReply's signal compression, we ended up not
emitting the readyRead signal for any of the data we received while
compressing the signals.

So, instead of relying on checking difference in bytes downloaded
for each batch of data received we keep track of how much data
we had received the last time we emitted readyRead.

Pick-to: 6.3 6.4 6.4.0
Fixes: QTBUG-106354
Change-Id: I4777be29b46bf0de968667e9de9d975c735ac6e6
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-09-12 13:06:50 +02:00
Mårten Nordheim
c288733541 Make tst_qnetworkreply depend on the 'echo' helper
Because it's convenient to have it build automatically.

Pick-to: 6.2 6.3 6.4
Change-Id: Iecd5bd1f9fe518f683b8ee9eb6529e48ce76fb33
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-09-12 01:20:19 +02:00
Timur Pocheptsov
9540a4eb90 QHttp2Configuration: in QNAM, use old, higher values in flow control
Initially, stream receive window's size was quite significant.
At some point when dealing with a server that did not want
our windows' sizes and was closing the connection (they only
accept 64K) we reduced this size, which ended in a regression
with download speed significantly throttled. We return the old
values (or even more, presuming we have 10 multiplexed streams
and not 100). And also making QNAM consistent with its documentation
(it was not updated).

[ChangeLog][QtNetwork] Stream receive window that HTTP/2 protocol in QNAM is using
increased to 214748364 octets (from the previous 64K) not to throttle download
speed. Clients, working with servers, not accepting such parameters,
must set HTTP/2 configuration on their requests accordingly.

Fixes: QTBUG-105043
Pick-to: 6.4 6.3 6.2
Change-Id: I252b6b5eefe92a7304dad15c67928d5a57d9597f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-08-30 20:20:38 +02:00
Lucie Gérard
32df595275 Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-23 23:58:42 +02:00
Marc Mutz
5ff7163796 qputenv: port to QByteArrayView
The vast majority of in-tree users pass simple and short C string
literals as the value. By porting to QByteArrayView, we document that
we'll accept non-NUL-terminated data, and do the NUL-termination
internally, using SSO'ed std::string, saving memory allocations in the
common case of short strings.

I didn't bother to check which direction std::string takes for
nullptrs these days (there was a change accepted in that area for
C++20 or 23), so play it safe and protect against them.

Follow-up to

Task-number: QTBUG-105302
Change-Id: I2369acc62f1d5cbc26135396cfe0602d8c75300c
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-08-06 14:21:46 +00:00
Lucie Gérard
fb1b20eab3 Add license headers to cmake files
CMakeLists.txt and .cmake files of significant size
(more than 2 lines according to our check in tst_license.pl)
now have the copyright and license header.

Existing copyright statements remain intact

Task-number: QTBUG-88621
Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-08-03 17:14:55 +02:00
Alexandru Croitor
4d22405e48 CMake: Don't use PUBLIC_LIBRARIES for tests and test helpers
Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-28 14:46:53 +02:00
Timur Pocheptsov
d8ff4d9f57 tst_qnetworkreply: replace server.pem/key pair
OpenSSL v3 fails to set server's certificate, complaining that
"md is too weak".

Pick-to: 6.4 6.3 6.2 5.15
Fixes: QTBUG-49205
Change-Id: Ib21b10ff13bc2621ae2aaaab962efaaf77a854bc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-07-15 22:42:43 +02:00
Lars Schmertmann
e3ea1d02e6 QHttpHeaderParser: Allow larger fields but restrict total size
Our limit of 8k for a single header field was too small for certain
services which returned Location values or WWW-Authenticate challenges
longer than 8k.

Instead, taking inspiration from Chromium, we have a limit of 250k for
the full header itself. And increasing our field limit to 100k, which
would occupy almost half of what the total header allows.

Also took the opportunity to make it adjustable from the outside so we
can set more strict limits in other components.

Fixes: QTBUG-104132
Pick-to: 6.3 6.4
Change-Id: Ibbe139445e79baaef30829cfbc9a59f884e96293
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2022-06-27 14:02:47 +02:00
Mårten Nordheim
6cbe8f74ce Network: Update expired cert
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I233ffee5b720c0554071c1d49d4fb861736b2e2a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-06-24 17:20:00 +00:00
Anna Wojciechowska
b885820c39 unblacklist passing tests 2022
Change-Id: Ifb09a997d39fc2c92503e77cf372d443c13c4c2b
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
2022-06-23 01:36:01 +02:00
Laszlo Papp
0a78cb7fab QNetworkReply: Fix the test compilation
It would not compile on my Linux box due to using QVariantMap, but not
actually including QMap itself. Using gcc 9.3.1 on CentOS 7.

Pick-to: 6.3 6.4
Change-Id: I808a270c814a906030cb34b197d3a2a85ba384e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
2022-06-10 20:57:19 +00:00
Ivan Solovev
e2e0420028 Network: update Public Suffix List
using the description from qtbase/src/network/kernel/qurltlds_p.h.INFO

Task-number: QTBUG-103663
Change-Id: I543fa96d2538f5eb63b114fe6467fb5b0e891e3b
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-05-23 22:28:49 +02:00
Lucie Gérard
05fc3aef53 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Task-number: QTBUG-67283
Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-16 16:37:38 +02:00
CI Insignificant Platforms Monitor Bot
d106caeac8 Blacklist: test cases blacklisted in tst_QNetworkReply:
- ioGetFromHttpWithProxyAuth on qnx

Pick-to: 6.2
Pick-to: 6.3
Task-number: QTBUG-103055
Change-Id: I45bf4c2df7fa977ffa525bf80108a74f1e8f4eef
Reviewed-by: CI Insignificant Platforms Monitor Bot <ci_insignificant_platforms_monitor_bot@qt.io>
2022-05-04 05:08:32 +00:00
Mårten Nordheim
b322984b49 tst_QNetworkReply try stabilize autoDeleteReplies tests
The http test data hasn't always been stable but for some reason
it fails far more than usual.

Originally the domain was a non-existing one, because it would then work
on any machine (even if not in CI) and would finish() (with error)
after failing to look up the domain in DNS. However, some machines in CI,
for some reason, take too long to do this and end up failing the test.

So, we change the URL to point to the network server in CI. This should,
at the very least, finish quickly when running in CI.

Pick-to: 6.3 6.2 5.15
Fixes: QTBUG-102952
Change-Id: I3b3f6fa23acf78fefdb69ff9ae7722f15e5f1736
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-04-29 04:28:56 +00:00
Mårten Nordheim
41d217829c QHttp: Fix handling of redirect loaded from cache
In some situations when loading a redirect from cache which would lead
to a real request we would not emit the finished() signal because the
replyFinished function has a pre-condition that the response did
not originate from the cache.
However, after the initial redirect was loaded from the cache we never
unset the 'loadingFromCache' boolean, so it was still true after the
request had been made to the real target.

Pick-to: 6.2 6.3 5.15
Change-Id: I015a2ebae4af4bd17392182c3951e875a7b353c4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-04-27 18:31:01 +02:00
Mårten Nordheim
d642c16fe7 QNetworkReply: update decompress error message and handling
The error message was quite vague since it would then not require
any additional translations. However, in hindsight this was a mistake
since now developers just thought their downloads were being corrupted.

Pick-to: 6.2 6.3
Fixes: QTBUG-101942
Change-Id: Ie9af42510ca027d15248e5bcf21e836e709898d9
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-04-27 18:31:01 +02:00
Sona Kurazyan
80363889fe Replace uses of _qba with _ba
Task-number: QTBUG-101408
Change-Id: I5175428c2be934b09f45bd06b0b47643003e25c7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-04-07 19:30:17 +02:00
Sona Kurazyan
a885f28933 Replace uses of _qs with _s in tests
Task-number: QTBUG-101408
Change-Id: If092a68828a1e8056259cf90d035d9a87989244b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-04-07 19:30:17 +02:00
Fabian Kosmale
819e1bf91d Tests: Do not depend on transitive includes
Change-Id: Ibc6a948480a904913a5427e6408d4d296784fb4f
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-03-17 17:14:37 +01:00
Sona Kurazyan
6585963583 Deprecate {QString, QByteArray}::count()
And remove their uses.

[ChangeLog][QtCore][Deprecation Notice] Deprecated QString::count()
and QByteArray::count() that take no parameters, to avoid confusion
with the algorithm overloads of the same name. They can be replaced
by size() or length() methods.

Change-Id: I6541e3235ab58cf750d89568d66d3b1d9bbd4a04
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-12 01:05:45 +01:00
Ievgenii Meshcheriakov
16b614f2e1 Network: Use system publicsuffix database copy when available
[ChangeLog][Network][QNetworkCookieJar] It is possible to use
system's copy of publicsuffix database when it is available.
This behavior is enabled by default on Linux and can be
controlled using new command line switches -system-publicsuffix,
-qt-publicsuffix, -no-publicsuffix, and -publicsuffix=all.

Fixes: QTBUG-95889
Change-Id: I911e1a13c1422cdc35851953309fff064e7c5f26
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-03 15:56:09 +01:00
Ievgenii Meshcheriakov
d0b22762be tst_qnetworkcookiejar: Remove tests that rely on public suffix database format
This format will be changed by the next commit. Also it is an
implimentation detail that can be changed at any time.

Task-number: QTBUG-95889
Change-Id: I00b1133078f1035e03e2cd6fae28192de54d2154
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-24 19:36:26 +01:00
Mårten Nordheim
db5b8bbea3 Http2: Fix redirect-handling
The redirect handling for http2 was a little simple. E.g. not handling
relative URLs.
Fix this using the redirect response parsing function which the http1
protocol handler already uses.

Fixes: QTBUG-100651
Pick-to: 6.3 6.2 5.15
Change-Id: Ic0cec4cacc92707e7a7fde1f4665f80995a6057e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-20 22:47:25 +01:00
Mårten Nordheim
9078b41dde QHttp: Move the emission of requestSent
Moved to after the header is actually written, not just generated.
For requests with data (put/post) we may have to wait for a callback
before the data to write is available. Since we then delay writing the
header as well it would be disingenuous to emit requestSent().

Pick-to: 6.3
Change-Id: I76c2d40ca48faaa1f6730ce8b3d5a8a4c3156f8f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-18 13:44:41 +01:00
Mårten Nordheim
50c8ec9fa4 QAbstractSocket: Don't pretend pause and resume is a stack
It only stores one layer of state, and pausing twice in a row will just
overwrite the previous state. This doesn't happen often but can happen,
especially on Windows if a certificate needs to be looked up in the system
certificate stores (socket gets paused) and then a recoverable error
occurs in QNAM (socket gets paused again).

Fixes: QTBUG-100362
Fixes: QTBUG-63196
Fixes: QTBUG-98476
Pick-to: 6.3 6.2 5.15
Change-Id: Ie524c48e11b6fa8010b78cc1bf3931efe2ce3351
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-09 22:26:20 +01:00
Pasi Petäjäjärvi
39310a6817 Handle situation when device running test does not have enough RAM
CI tests for QNX are run in QEMU which does not have enough RAM
to run this test successfully.

Pick-to: 6.2 6.3
Change-Id: Idab3e8b6a1e0ae3eddf5aedb82e6784a74ae9a3a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-09 14:17:53 +00:00
Fabian Kosmale
987b896b4e Blacklist putWithServerClosingConnectionImmediately on Windows
Task-number: QTBUG-100362
Change-Id: Ib09aec5ea03867163d476a2c92562bc949fc1b1a
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-02 05:25:06 +01:00
Mårten Nordheim
8437c27582 QNetworkReply: rename socketConnecting to socketStartedConnecting
From the API review.

Pick-to: 6.3
Change-Id: Ic05737db79327e7811fcd974a70914b837e06601
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-31 14:24:11 +01:00
Joerg Bornemann
238e3beb6f Remove unused .qrc files
Task-number: QTBUG-94446
Change-Id: I136d8b4ab070a832866aa50b5701fc6bd863df8a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-17 23:17:01 +01:00
Edward Welbourne
aa8fd6bc39 Convert date-time to UTC before claiming it's in GMT
QNetworkHeadersPrivate::toHttpDate() used a custom format to output a
date-time; the format supplied GMT as suffix, but neglected to convert
the date-time to UTC, so local-time was formatted as if it were UTC,
regardless of its actual offset from it. Fixing this (by the obvious
toUTC() call) broke formatting when the supplied header value was a
QDate, since it's packaged as a QVariant and QVariant's conversion of
QDate to QDateTime uses local time's (not UTC's) start of day. So fix
headerValue() to separate QDate and QDateTime cases and use
startOfDay(Qt::UTC) to get the right start of the day. Added tests for
non-UTC date-times appearing correctly in HTTP headers.

Fixes: QTBUG-80666
Pick-to: 6.3 6.2 6.2.3 5.15
Change-Id: I2792bce14a07be025cf551b0594630260c112269
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-17 22:29:30 +01:00
Mårten Nordheim
9909ec0bc6 QNAM: Reintroduce h2c with an attribute
[ChangeLog][QtNetwork][QNetworkRequest] Added
QNetworkRequest::Http2CleartextAllowedAttribute which controls whether
HTTP/2 cleartext (h2c) is allowed or not. The default is false. This
replaces the QT_NETWORK_H2C_ALLOWED environment variable.

Task-number: QTBUG-98642
Change-Id: I43ae1cc671788f6d2559cd316f6667b412c8e75e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-12-04 08:20:52 +00:00
Mårten Nordheim
4c930e9d13 QNAM: Disable h2c by default
And since it's relatively unlikely to be used, just leave it
behind a environment variable for now.

[ChangeLog][QtNetwork][Potentially Source-Incompatible] Support for
clear-text http/2 was disabled due to incompatibility with certain
servers. If you were relying on this feature you must re-enable it by
setting the QT_NETWORK_ALLOW_H2C environment variable. For a later
version of Qt it will get a dedicated attribute.

Pick-to: 6.2
Task-number: QTBUG-98642
Change-Id: Id3e360726e285b3128e3e3f4bce9440404c9ad6e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-11-30 00:04:38 +01:00
Øystein Heskestad
18aff2b424 Add more verification when parsing http headers and add tests
Adding tests from QtWebSockets that will reuse QHttpHeaderParser

Task-number: QTBUG-80700
Change-Id: I76294a9156173314a3cf09160d0ca4e0d7c6ef3a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-19 19:31:34 +01:00
Timur Pocheptsov
dd57605b9e Http/2 - handle PADDED flag correctly
Previously, when deciding where the actual data is, Frame was calling
padding() to test if offset is needed. A curious case with a DATA frame
containing compressed body and having 'PADDED' flag set with a padding
equal to ... 0, ended in a decompression error (and assert in 6.2 code).

Pick-to: 6.2 5.15
Fixes: QTBUG-97179
Change-Id: I9341a4d68510aa4c26f4972afdcd09a530d5a367
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-10-09 12:49:01 +02:00
Volker Hilsheimer
af31b6cf05 Silence compiler warning from int/size_t mismatch
Amends 4757b93b0e.

Change-Id: I678785cd61dbdecb3b1e7e68c7daf9f18cad4d02
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-10-07 00:49:17 +02:00
Tatiana Borisova
766904bf5b Compile autotests for Integrity
- process environment/DNS are OFF for INTEGRITY

Task-number: QTBUG-96176
Pick-to: 6.2
Change-Id: I189a97f88c96a428586c31a66b8d250e04482900
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-20 17:29:04 +03:00