Commit Graph

1735 Commits (5ea248155654b58fcb52ef326dc4d94de83d0409)

Author SHA1 Message Date
Lena Biliaieva fb2ea1e52a tst_QNetworkRequest: add test for operator==()
Task-number: QTBUG-107751
Change-Id: I4ed77b022f9e576f1363d55a05de6f6fad5b01dc
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-05-07 21:28:59 +02:00
Lena Biliaieva 0fef8f53c3 Use QHttpHeaders: Update internal users of QNRequest, QNReply, QNProxy
Replace QNetworkHeadersPrivate's main headers storage, which was
RawHeadersList, with QHttpHeaders. Replace internal usage of raw and
cooked header methods with the QHttpHeaders API.

[ChangeLog][QtNetwork][QNetworkRequest] Header value added by
QNetworkRequest::setRawHeader() method is trimmed now.

Task-number: QTBUG-107751
Change-Id: I8882978afa430651e6c798a4fed00beef6c4cfd2
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-05-07 12:39:23 +02:00
Jari Helaakoski 30cc8a28de Fix test compilation issues with QtLite configuration
Now developer build tests compile, but some are not working.
Functional fix will come later via separate tasks.

Task-number: QTBUG-122999
Change-Id: I70487b46c1b32ba4279cb02a4978e4f55ac0d310
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-06 14:29:02 +00:00
Mate Barany 3377b74df9 Add QDebug support to QHttpPart
As part of QTBUG-114647 we are planning to introduce a deduction
mechanism that could deduce the contentType header and the
contentDisposition headers based on the arguments (and the MIME
database).

In case of non-trivial types this deduction may give the wrong result
and without QDebug support it might be a bit tedious to check.

The debug output displays some information about the body device if
one is attached, otherwise it displays the size of the body.

Task-number: QTBUG-114647
Change-Id: Ia693b078ff5b9f8ea57fbf3c385edaec47886ff1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-05-03 15:16:14 +00:00
Ari Parkkila 53a58a191c ptests: Skip qlocalsocket when running as root on Linux
On Linux root user has access rights to all files so it makes no sense
to verify socket file permissions.

Task-number: QTBUG-118680
Change-Id: I94a95e80c311f8d5cd6c799b1a76ffaaab7d9167
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-03 11:58:54 +03:00
Marc Mutz 834e7d60a9 QRestReply: allow comments where white-space is allowed
This is RFC2822 grammar (except that line folding is not
allowed).

RFC9110 doesn't allow it anymore, but it might make sense to accept it
nonetheless (Postel's Law).

Pick-to: 6.7
Task-number: QTBUG-123544
Change-Id: Ie990cd332c7603dbdae29c19b2804bd33a058ca0
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-05-03 01:05:07 +02:00
Lena Biliaieva 78b0d507ce Add QHttpHeaders methods to QNetworkCacheMetaData
[ChangeLog][QtNetwork][QNetworkCacheMetaData] Added headers() and
setHeaders() methods to QNetworkCacheMetaData to provide an interface
to work with QHttpHeaders.

Task-number: QTBUG-107751
Change-Id: I1dfed5c2e03f4912de0da96156425cd6b713c1d5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-05-02 22:11:44 +02:00
Lena Biliaieva fa456ad550 Add QHttpHeaders to QNetworkRequest
Added headers() and setHeaders() methods to QNetworkRequest.

[ChangeLog][QtNetwork][QNetworkRequest] Added headers() and setHeaders()
methods to QNetworkRequest, which provide an interface to work with
QHttpHeaders.

Task-number: QTBUG-107751
Change-Id: I2e1dc7cb2efab5903eb7ff23b75d01aefe13273d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-04-29 18:26:15 +02:00
Marc Mutz 98b034e53a QRestReply: make charset parsing more robust
The old code was based on QString::split and e.g. didn't handle
escapes in quoted-strings.

Write a modern recursive-descent parser to parse out type/subtype and
charset parameter. Since we don't, yet, support CFWS (see below),
recursion depth is strictly limited, so we're not susceptible to
recursion bombs here.

It currently handles only RFC9110-style grammar, but can be easily
extended to support CFWS (RFC2822-style comments and folding
white-space) or RFC2231-style continuuations, if needed.

It's a bit more general than strictly required, because I expect this
to be reused elsewhere ere long.

Pick-to: 6.7
Fixes: QTBUG-120307
Change-Id: I309928dc350a043672dffb4a259b457764c031be
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-04-26 02:24:53 +02:00
Marc Mutz 2822b22610 QRestReply: add a few more content-type parsing tests
... incl. some that fail.

This is in preparation of a patch that makes the parser more
compliant.

Pick-to: 6.7
Task-number: QTBUG-120307
Change-Id: Ic47b23132f2a7ea81b6c480bfb036bc2daff05da
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-04-24 21:36:49 +02:00
Thiago Macieira f110bd2663 tst_QDnsLookup: add testing of PTR records on global names
The DNS servers from Google and CloudFare are probably stable enough
over the long-term.

Change-Id: I455fe22ef4ad4b2f9b01fffd17c748dc1233bc1b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-04-22 21:36:30 -07:00
Thiago Macieira 6800e168d5 tst_QDnsLookup: also use the nameservers behind systemd-resolved
If the file exists, we are using systemd-resolved, so let's try directly
using the nameservers it uses.

Change-Id: I455fe22ef4ad4b2f9b01fffd17c7476a2385bf4b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-04-22 21:36:30 -07:00
Thiago Macieira f7d293d3da tst_QDnsLookup refactor: use the new helpers in other test functions
Change-Id: I455fe22ef4ad4b2f9b01fffd17c7414e111cb8ed
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-04-22 21:36:30 -07:00
Thiago Macieira 4b8bdab27d tst_QDnsLookup refactor: rewrite lookup() function
This is a major simplification to use only one column in the QtTest
tables for the results, which makes it far easier to read the code as
well as to add more record types.

Change-Id: I455fe22ef4ad4b2f9b01fffd17c745d13c9c4037
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-04-22 21:36:30 -07:00
Thiago Macieira 121a081d20 tst_QDnsLookup refactor: split the NXDOMAIN tests from lookup()
This will allow making lookup() require positive results only.

Change-Id: I455fe22ef4ad4b2f9b01fffd17c740e36002d25e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-04-22 21:36:30 -07:00
Thiago Macieira 41675df695 tst_QDnsLookup: use the 4-argument writeDatagram() overload
When using writeDatagram(QNetworkDatagram), the sendmsg() call on
FreeBSD is failing. It works on Linux and on macOS, so my guess is that
IP_PKTINFO works to set the sender address but IP_SENDSRCADDR is not
allowed in this context for some reason.

Before:
 recvmsg(5,{{ AF_INET 127.0.0.1:19530 },16,[{"H\M-p\^A\0\0\^A\0\0\0\0\0\^A\tso"...,49}],1,{{level=IPPROTO_IP,type=IP_RECVDSTADDR,data={0x7f,0x00,0x00,0x01}},{level=IPPROTO_IP,type=IP_RECVTTL,data={0x40}}},48,0},0) = 49 (0x31)
 sendmsg(5,{{ AF_INET 127.0.0.1:19530 },16,[{"H\M-p\M^@\^C\0\^A\0\0\0\0\0\^A\t"...,49}],1,{{level=IPPROTO_IP,type=IP_RECVDSTADDR,data={0x7f,0x00,0x00,0x01}}},24,0},MSG_NOSIGNAL) ERR#22 'Invalid argument'

After:
 recvmsg(5,{{ AF_INET 127.0.0.1:16018 },16,[{"\^U\M-X\^A\0\0\^A\0\0\0\0\0\^A\t"...,49}],1,{{level=IPPROTO_IP,type=IP_RECVDSTADDR,data={0x7f,0x00,0x00,0x01}},{level=IPPROTO_IP,type=IP_RECVTTL,data={0x40}}},48,0},0) = 49 (0x31)
 sendmsg(5,{{ AF_INET 127.0.0.1:16018 },16,[{"\^U\M-X\M^@\^C\0\^A\0\0\0\0\0\^A"...,49}],1,{},0,0},MSG_NOSIGNAL) = 49 (0x31)

Pick-to: 6.7
Change-Id: I455fe22ef4ad4b2f9b01fffd17c77565e230ce31
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-04-22 21:36:29 -07:00
Thiago Macieira 2dfb7f3337 tst_QDnsLookup: fix MSVC 'truncation of constant value' warning
0x80 is too big for a signed char (range is -0x80 to 0x7f).

Pick-to: 6.7
Change-Id: I455fe22ef4ad4b2f9b01fffd17c7746f4ea3c536
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-04-22 21:36:29 -07:00
Mårten Nordheim 4f9387f2ae Http2: fix handling unsuppported authenticate challenge
When adding/fixing parts earlier it was missed that it was not handling
the _unsupported_ case, when authentication is not handled and there is
no resend. But there _is_ a challenge header.

Pick-to: 6.7 6.6 6.5
Fixes: QTBUG-123891
Change-Id: I21470df0ce2528bad3babffc6e9f19b7afd29d20
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-04-20 13:48:37 +02:00
Marc Mutz a564618838 HttpTestServer: pass std::function by value and move into place
Virtually all callers of this function (will) pass rvalues, so take
the std::function by value (reaping C++17 guaranteed copy elision) and
std::move() into the member variable ("perfect sink").

Like for many owning types, moves are much cheaper than copies for
std::function, because the external state is merely tranferred between
objects, and not copied.

Amends e560adef21.

Pick-to: 6.7
Change-Id: I269b54e51ba09ac595ac4e4f255209778819adad
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-04-18 19:06:02 +02:00
Marc Mutz 5b6c6dab63 tst_QRestAccessManager: fix signature of server handlers
HttpTestServer::Handler is declared to take the first argument by
reference to const, not by value, so use the same parameter passing
for the lambdas passed to setHandler().

Avoids copying the (rather large) argument when invoked through the
std::function wrapper, and silences clazy-function-args-by-ref.

Pick-to: 6.7
Change-Id: I726d0b98a7fcb3b1b33c5bde203035f593c39bdd
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-04-18 19:06:02 +02:00
Marc Mutz d4aaf61b33 tst_QRestAccessManager: leak less on failure
Move some deleteLater() calls to before the first QCOMPARE/QVERIFY
macros, so they get executed even if the macros return on failure.

This isn't an all-encompassing solution, but I lack the time to port
all this to smart pointers, and this is some improvement.

As a drive-by, port QVERIFY(opt.has_value()) to QCOMPARE(opt, nullopt).

Task-number: QTBUG-120307
Pick-to: 6.7
Change-Id: Ia5a2cabd273a779938b22badc91b109fcc545203
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-04-18 19:06:01 +02:00
Mårten Nordheim b85acc8356 tst_QHttpNetworkConnection: Move to use only one ctor
We want to get rid of the other one, it's all internal
API anyway.

Task-number: QTBUG-102855
Change-Id: I2b621c20f4dd7c8bf5f07db8db908c2b7b86976f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2024-04-17 20:30:36 +02:00
Giuseppe D'Angelo c68f8db62b Tests: make some QFile::open calls fail
In some cases calls to QFile::open are made outside of a testfunction
(so we can't use QVERIFY), or even in standalone executables that are
executed by tests. Make them fail "visibly".

Change-Id: Iec4d56f6d874be16aa2e9ad6974eeec2a98caa3f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-04-13 01:36:06 +02:00
Mårten Nordheim 1d03e1851b QHttp2Connection: fix handling of replies on locally initiated stream
It was overlooked in testing, but it would emit a signal for new
incoming stream even if the server was just replying with HEADERS on a
stream the client had initiated. Or vice-versa.

Pick-to: 6.7
Change-Id: Ie7b3a45729a78106da1d8c058e15705cc7dcc53b
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-04-11 21:53:59 +02:00
Giuseppe D'Angelo 58ff4e22f7 tst_qnetworkreply: verify we can open the local file for comparison
... except for bigfile.

Change-Id: Ide04a9c80b438272e868a6d2b410a507c76d6239
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-04-03 23:57:45 +01:00
Giuseppe D'Angelo 8414a0aa2c Tests: check the output of QFile::open
Wrap the call in QVERIFY.

tst_QTextStream::read0d0d0a was also faulty as it *never* opened
the file because of a broken path. Fix it with QFINDTESTDATA.

Change-Id: I61a8f83beddf098d37fda13cb3bfb4aaa4913fc5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-27 04:24:11 +01:00
Marc Mutz 20eba275d8 tst_QNetworkReply: don't leak on failure in emitErrorForAllReplies()
The old code allocated QSignalSpies on the heap and stored them in a
non-owning container, so if one of the many check macros trigger,
those objects would be leaked. Ditto QNetworkReplies. The code also
used dynamically-sized containers for statically-sized data; a common
anti-pattern.

Hold the sample QUrls in a C array instead, QSignalSpies in C arrays
of std::optional (to delay initialization) and QNetworkReplies in a C
array of std::unique_ptr with the existing QScopedPointerDeleteLater
deleter.

Pick-to: 6.7
Change-Id: I7305115af15c079abba6d45c5de8db2198ea7a6d
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-03-21 11:20:49 +01:00
Marc Mutz eefd8ab1e8 tst_QNetworkReply: don't use deleteLater() on QSignalSpies
Turn the QSignalSpy deletions from deferred (via deleteLater()) into
immediate ones. This is ok: QSignalSpy is using itself as a context
object in QMetaObject::connect(), so the connection thus established
to the monitored signal will be atomically severed if either sender or
receiver are destroyed. There never was a need to defer deletion of
the signal spy, so don't.

Found by making QSignalSpy's inheritance from QObject private.

Pick-to: 6.7 6.6 6.5
Change-Id: I962d28c3a78f356d234324fed68716f2f1052100
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-20 21:22:12 +01:00
Marc Mutz 17d2550ed0 tst_QNetworkReply: use QtCore's QScopedPointerDeleteLater
... instead of rolling your own.

Pick-to: 6.7 6.6 6.5
Change-Id: I4fee2218eb874bfee34bd3a0abac3f85b0746540
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-20 21:21:29 +01:00
Mate Barany 282839ad41 Add a means to send a PUT request with an empty body
We have implemented the same functionality recently for POST, in this
patch implement it for PUT.

Task-number: QTBUG-108309
Change-Id: I34c41538054fec836d0d1d1dbb44fabab9bc0e9a
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-19 13:01:31 +01:00
Mate Barany e566a8a968 Add a means to send a POST request that has an empty body
Actually this has already worked if a nullptr was casted as a
QIODevice*. Add an overload with a nullptr_t type, that does
this behind the scenes.

Fixes: QTBUG-108309
Change-Id: I2d4b17ae94cf4de2c42257d471ef901c8994fee5
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-19 13:01:31 +01:00
Mårten Nordheim 88763730cc tst_qnetworkreply::httpConnectionCount: tentatively increase timeout
It is failing a bunch on macOS in CI, but not locally.
So just assuming the timings are too tight in CI and increasing
them.

Amends 8de1ed8979

Pick-to: 6.7
Change-Id: Icb44fdbd2aa117de7350c5df2e8351bb19c865c4
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2024-03-18 17:42:19 +01:00
Mårten Nordheim 5e102a792c tst_QNetworkReply: cleanup changed state from timeout test
It was not setting the value _back_ to 0 when the function ended
and this caused qtbug68821proxyError to fail fairly consistently
on Windows when it was running in the same run.

qtbug68821proxyError was always succeeding when ran by itself so
it was quite odd.

Pick-to: 6.7
Change-Id: Ifa4982f1b10128674081136a30bdab4b0ce7004a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-03-14 19:01:43 +01:00
Thiago Macieira d18d8a7ad1 tst_QHostInfo: increase the timeout to 15s
That seems to be enough for me when trying to reverse-resolve host names
inside the corporate network.

Pick-to: 6.7
Change-Id: I6818d78a57394e37857bfffd17bc6b0ebd39f51b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-13 18:29:12 -07:00
Thiago Macieira 78cf5740a9 tst_QHostInfo: don't use the test class to store results
Because QHostInfo is threaded, so if the look up times out and we exit a
given test, the results may still be delivered to the next test.
Especially if the next test is also about to time out -- in which case
it doesn't and prints a nonsensical output.

Before:

FAIL!  : tst_QHostInfo::lookupIPv4(WithCache:literal_ip4) '!QTestEventLoop::instance().timeout()' returned FALSE. ()
   Loc: [tst_qhostinfo.cpp(220)]
FAIL!  : tst_QHostInfo::lookupIPv6(WithCache:aaaa-single) Compared values are not the same
   Actual   (tmp.join(' ').toLower())     : "192.0.2.1"
   Expected (expected.join(' ').toLower()): "2001:db8::1"
   Loc: [tst_qhostinfo.cpp(281)]

Now:

FAIL!  : tst_QHostInfo::lookupIPv4(WithCache:literal_ip4) 'helper.waitForResults()' returned FALSE. ()
   Loc: [tst_qhostinfo.cpp(278)]
PASS   : tst_QHostInfo::lookupIPv6(WithCache:aaaa-single)

Pick-to: 6.7
Change-Id: I6818d78a57394e37857bfffd17bc66e241cab24d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-14 01:29:12 +00:00
Alexandru Croitor fb69efb9c9 CMake: Make a few more auto tests standalone
Pick-to: 6.7
Change-Id: I80988114bd906447a2ab712d5432a489e095a5c1
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-14 01:14:18 +01:00
Mårten Nordheim 8de1ed8979 tst_QNetworkReply: update and speed up httpConnectionCount
Because we will do a small wait after the final connection (to see
if there are any unexpected extra connections) we can save some time
by reducing _how long_ we wait for it.
In general we only need an extra long wait for the first connection,
subsequent connections are faster.
So we change the loop structure from looping until we hit 20(!)
connections, when anything larger than 6 will fail the test anyway!
And use qWaitFor instead of repeatedly calling enterLoop and checking
the state of an ElapsedTimer, the total wait time is not super
interesting, and made it a guarantee that the test would take 10
seconds.

While we are here, update the attribute we use to test HTTP/2
connections. We were previously enabling http/2, but this is the new
default so it's not needed. We do, however, need to enable h2c if we
want to see it trying to upgrade to http/2 over cleartext.

Not a big issue, so we don't pick it very far back.

Pick-to: 6.7
Change-Id: Ia314ae2827ab8a8baaa4af2c5136c5e531bcb1f8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-12 14:23:57 +01:00
Mårten Nordheim be6644c1f2 Http: fix issues after early abort()
There were a few issues to deal with. One of them was that we would
print a warning about an internal error if we tried to *set* an error
on the reply after it had been cancelled. That's kind of unavoidable
since these things happen in different threads, so just ignore the
error if we have been cancelled.

The other issue was that, for a request with data, we will buffer the
data to send, and _only then_ do we start the request. This happens
asynchronously, so the user can abort the request before it has finished
buffering. Once it finished buffering it would set the state of the
request to "Working", ignoring that it was already marked "Finished".

Fixes: QTBUG-118209
Fixes: QTBUG-36127
Pick-to: 6.7 6.6
Change-Id: Idbf1fd8a80530d802bee04c4b0a6783cba4992d3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-03-12 14:23:56 +01:00
Juha Vuolle d8f6425fef Add a QHttpHeaders convenience method for unique header name setting
The function replaces one of the found entries with the new value,
and removes any other entries. If no entries are found, a new entry
will be appended. The replacement search is done for performance
reasons; it's cheaper to replace an existing value.

All in all the function is a more convenient and performant
alternative for this sequence (which proved to be common while
porting QtNetwork internals to QHttpHeaders):
header.removeAll(<headername>);
header.append(<headername>, <value>);

[ChangeLog][QtNetwork][QHttpHeaders] Added replaceOrAppend()
convenience method, which either replaces previous entries with
a single entry, or appends a new one if no entries existed

Fixes: QTBUG-122175
Change-Id: I03957645d7e916a732ac7b8d3ae724bb6b16af87
Reviewed-by: Lena Biliaieva <lena.biliaieva@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-07 23:38:09 +02:00
Lucie Gérard 7b6289a035 Correct license for tools files
According to QUIP-18 [1], all tools file should be
LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: Icd5d5be2e04819617e68ff142924de1773bebbad
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-03-05 12:59:21 +01:00
Matthias Rauter 3f26fdebbc Implement ping reply in QHttp2Connection and add test
Fixes: QTBUG-122338
Change-Id: I1e8dfa8a93c45dbe12a628d4d5e79d494d8f6032
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-04 20:14:36 +01:00
Mårten Nordheim b2ff0c2dc2 UDP: don't disable read notification unless we have a datagram
The current logic that we will disable the read notification if we
have any data at all doesn't make sense for users who use the
receiveDatagram functionality, since they will not make any calls
that trigger the read notifier to be re-enabled unless there is a
datagram ready for us to hand back.

Fixes: QTBUG-105871
Pick-to: 6.7 6.6 6.5
Change-Id: I0a1f1f8babb037d923d1124c2603b1cb466cfe18
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-02 22:57:09 +01:00
Mate Barany 6d08db8666 Handle informational HTTP replies (1xx) for HTTP/2
Make QHttp2ProtocolHandler discard all informational (1xx) replies with
the exception of 101.

According to RFC 9110:

"A client MUST be able to parse one or more 1xx responses received
prior to a final response, even if the client does not expect one.
A user agent MAY ignore unexpected 1xx responses."

Fixes: QTBUG-121755
Change-Id: I8b8d578f23d4fbe28929f8c54b3607bcaf85405f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-03-01 23:57:13 +01:00
Mårten Nordheim 788ce26882 tst_qudpsocket: add helper exe to dependencies
Pick-to: 6.7 6.6 6.5
Change-Id: I2bea493c5273175746d502e62d1044eca20ece04
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-02-29 14:56:11 +01:00
Juha Vuolle 0119f0a43b Add QNetworkRequest attribute support to QNetworkRequestFactory
[ChangeLog][QtNetwork][QNetworkRequestFactory] Add QNetworkRequest
attribute support to QNetworkRequestFactory

Fixes: QTBUG-122397
Change-Id: Ie73f104cdad9f8f0721d8ee28f79095bfb04fb3c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-02-28 08:13:55 +02:00
Juha Vuolle 1fbcb411e1 Add space character when combining QHttpHeaders values with comma
The "HTTP RFC 9110 5.3 Field Order" states that the values combined
with comma can be followed up by an optional whitespace, and for
consistency recommends "comma SP". This is also what eg. 'MDN Web
Headers' class does.

Fixes: QTBUG-122650
Pick-to: 6.7
Change-Id: I3391c86018090f0b8721929b64a7e3029e98ac85
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-02-27 11:42:11 +02:00
Mårten Nordheim 775a57f266 tst_QNetworkReply: Try to stabilize qtbug68821proxyError
The test is a bit silly, it was originally written to make sure that
we produce meaningful errors when trying to connect to a proxy server
where the connection is refused or the server doesn't respond at all.

To test that, it creates a local QTcpServer and starts listening to any
free port (by specifying port 0) and then it closed the server and
uses the address-port of localhost:serverPort as the proxy to use, since
we know it _was_ unused, since we were able to bind to it.

However, just calling close() doesn't immediately tear down the internal
socket descriptor, so the OS may still have the port reserved for
some time.

By moving the QTcpServer to a narrower scope we will quickly destroy it
and the internal socket engine, which is parented to the server, and
this in turn releases the socket descriptor.

Pick-to: 6.7 6.6 6.5
Change-Id: If12128fc21d1f545df152f08f0d52c1b14ac6037
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-02-15 16:27:19 +01:00
Mårten Nordheim 3b3b2024f9 Add QNetworkRequestFactory::(set)?Priority
To enable setting a default priority for all requests to a given site.

Fixes: QTBUG-121669
Change-Id: Icd8a9c59e4afb0432c65f84cc8115ae0c7f85506
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-02-08 11:38:10 +01:00
Juha Vuolle cdfeca26cf Remove HTTP 1XX status test from tst_qrestaccessmanager
1XX statuses are not final statuses, and testing 'error' on it is not
necessarily very meaningful. Furthermore the internal handling of
these statuses changes in Qt 6.8.

Fixes: QTBUG-108068
Pick-to: 6.7
Change-Id: I9c18c579cd310266273eccd2aee2e032f60538e0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-02-06 19:10:45 +02:00
Mate Barany bb34c6fa6b Make QNAM handle all informational HTTP replies
Make QNetworkAccessManager to discard all informational (1xx) replies
from HTTP servers with the exception of 101.

According to RFC 9110:

"A client MUST be able to parse one or more 1xx responses received
prior to a final response, even if the client does not expect one.
A user agent MAY ignore unexpected 1xx responses."

Status code 101 is an exception because we use it to upgrade to http2
cleartext when it is enabled.

Fixes: QTBUG-108068
Change-Id: I415ff053180a43f0c7ff1b4b2a60fd114ce08ac9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-02-06 19:10:45 +02:00