The new public API returns and notifies changes to the currently active
transport medium for the application. And there's a new private API to
report it, with backends to follow.
Task-number: QTBUG-91023
Change-Id: I527985f9dabcd7bc4a32f36597e21bc4ab664c4e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Update the build.gradle for main Qt jar code, and add same files for
network and network information backend, so the code can be managed
from Android Studio.
This also adds .gitignore to ignore Android Studio build artefacts.
Pick-to: 6.2
Change-Id: Ic06e9d12708070fad112f17e58b8754608d184f3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
After calling close(), the socket can enter 'Closing' state, in which
we try to write buffered data before disconnecting. As the device is
already closed, we must disable any pipe reader activity and clear the
read buffer.
Change-Id: I8994df32bf324325d54dd36cbe1a1ee3f08022d1
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
The client and server do in practice depend on each other.
So setting up things is a tad more complicated, and the use
case not big enough to warrant both to be highlighted.
Task-number: QTBUG-96575
Pick-to: 6.2
Change-Id: I0ed69f7a20ec490cc977bde7f1b09162153d0bd2
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Calling pipeWriter->checkForWrite() can indirectly close the socket
even if the bytesWritten() signal has not been sent. So, we need to
make sure the handle is valid before checking pipe state in the
reader.
There is no harm in calling PeekNamedPipe() with an invalid handle,
but the wrong call should be avoided.
This patch amends b2c3b3e8fe.
Change-Id: I5d2ecbbbe0af817aac68ad6f1173b0ed9b324e98
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
The QtNetwork project file excludes the dnslookup source files for Unix,
despite the dnslookup feature is always on. This inconsistency leads to
linker errors when building applications against QtNetwork:
(error #412) unresolved symbols: 1
QDnsLookupRunnable::query(int, const QByteArray &, const QHostAddress
&, QDnsLookupReply *) from libQt6Network.a(qdnslookup.cpp.o)
Turn the feature off for INTEGRITY and remove the condition from the
project file.
Pick-to: 6.2
Change-Id: If086da51ca343f598eb273236e7b6338f5da1e97
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
The documentation links on `msdn.microsoft.com` now redirect to
`docs.microsoft.com`.
While the redirection works, our script to catch broken links on
dev-snapshots builds of the documentation doesn't handle redirection
correctly, reporting it as broken.
Both to appease the broken-links script and to avoid an unneccesary
redirection, the links were modified to point to the equivalent address
in the new domain.
Furthermore, the link to the `Winsock 2 Socket Handle` was moved to be
an `\externalpage` link, as it was used in two different places.
Additionally, the `\externalpage` link titled `Dirext X SDK` was removed
as it was not used in any part of the documentation.
Task-number: QTBUG-96127
Pick-to: 6.2 6.2.0
Change-Id: I07f0ae8d610a7f8322b892a2fa37a5cc1769289e
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Needed for subsequent change that will check and error out if the
version is lower than 3.16. We do that to ensure all policies
introduced by CMake up to version 3.16 have their behavior set to
NEW.
Pick-to: 6.2
Task-number: QTBUG-95018
Change-Id: Ieaf82c10987dd797d86a3fd4a986a67e72de486a
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
When we load by name we used to pass an empty QList to the backend as
the list of requested features. That's not ideal if a backend were to
selectively initialize components, so let's just pass the list of
supported features.
Not a problem in any current backend but it looks weird.
Pick-to: 6.2
Change-Id: Ib022778b08d32e4057103a86bfdda9e17e6ebdaf
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
To allow reading from a slot connected to the aboutToClose() signal,
we should call QIODevice::close() just before closing the inner device.
This patch amends 21f3ff65b8.
Pick-to: 6.2
Change-Id: Ic8cd00497e1bdf923b980c26e9ca874b77e82f89
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
The docs (10 lines above) say it will find the backend case
insensitively. Thus the comparison should also be case-insensitive.
Pick-to: 6.2
Change-Id: I65901ed81b7d8bdfcf76f5b6c7b40efe63245503
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
To match the Unix behavior, we should emit errorOccurred() signal and
close the channel if the write operation fails.
Change-Id: Iac3acb18dbbfe6e7e8afb2555d9adaff1fe98d0f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
In a blocking application, receiving the results of write operations
must be synchronized with the waitFor...() functions. But, clearing
the buffer in another thread can cause the code
localsocket.write(...);
QVERIFY(localsocket.bytesToWrite() > 0);
to fail unexpectedly, if the socket has been disconnected between
the calls.
So, defer resetting the buffer until checkForWrite() is called.
Change-Id: I8c21036aab6a4c56d02c0d9a18d4bbce52d724f4
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
In the effort of repairing broken links as per QTBUG-96127,
a series of RFC links referring to `tools.ietf.org/html/*` were modified
to point to the new address that the site redirected to.
To simplify executing a similar task and to diminish the duplication of
manually inserted urls, the already existing `rfc.qdoc` file, containing
`\externalpage` commands directing to RFC locations, was enhanced with
links to all RFCs that were mentioned in the current documentation, so
as to aggregate this common category of links.
All links pointing to a `ietf` domain inside QDoc documentation blocks
were then changed to use the newly provided external-references.
Task-number: QTBUG-96127
Pick-to: 6.2
Change-Id: I2a52eb6aa8c9e346f64ef1a627b039220d9f6c2a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The link was to `msdn.microsoft.com` which now redirects to
`docs.microsoft.com`.
While the redirection works, our script to catch broken links on
dev-snapshots builds of the documentation doesn't handle redirection
correctly, reporting it as broken.
Both to appease the broken-links script and to avoid an unneccesary
redirection, the Winsock link in `qlocalsocket.cpp` was modified to
point to the new address.
Task-number: QTBUG-96127
Pick-to: 6.2
Change-Id: Idff5c2e96f7c90259219a554f73e16c37b81cafe
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The Clang compiler used in QDoc complained about the documentation-
specific overload of QAbstractSocket::bind():
error: incomplete type 'QHostAddress' named in nested name specifier
Also, fix an attempted snippet inclusion to use the \include command,
and fix the comment tag spacing and indentation.
Pick-to: 6.2
Fixes: QTBUG-96293
Change-Id: Ie4d78933fa7ac0aaf7f3bcc6487e7fd823db5123
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
The file qt_lib_network_private.pri contained the following bit
QMAKE_LIBS_OPENSSL/NOLINK =
QMAKE_INCDIR_OPENSSL/NOLINK = C:/openssl/include
QMAKE_LIBS_OPENSSL =
QMAKE_LIBS_OPENSSL_DEBUG = -L"C:/openssl/lib/VC" -llibssl64MDd
QMAKE_LIBS_OPENSSL_RELEASE = -L"C:/openssl/lib/VC" -llibssl64MD
QMAKE_INCDIR_OPENSSL = C:/openssl/include
The /NOLINK entries are nonsense. QMake projects that do
QMAKE_USE += openssl/nolink
would use QMAKE_INCDIR_OPENSSL and discard the QMAKE_LIBS_OPENSSL*
variables.
The QMAKE_*_OPENSSL/NOLINK entries stem from the WrapOpenSSLHeaders
CMake package, and QMAKE_*_OPENSSL from WrapOpenSSL. It's safe to
assume that both packages use the same include paths.
Remove the QMAKE_LIB parameter from the
qt_find_package(WrapOpenSSLHeaders) call to avoid writing this library
into the .pri file.
Pick-to: 6.2
Fixes: QTBUG-89562
Change-Id: Ibc20f6f90678eb127db7813eb63c5c3e0bff2268
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
customFilters defined in .qdocconf are not supported anymore by Qt
Assistant since Qt 5.13. Therefore remove them from all .qdocconf files,
also to avoid cargo-culting them to new help modules.
Task-number: QTBUG-95987
Change-Id: I664391460637d2e859348da0338e1a4a3ee9f570
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
QDeadlineTimer is semantically more correct than comparing timestamps to
'now'.
Change-Id: I15d9654af2886499392e6409d22f802203aca18d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Instead of for any debug output.
Since QTestLib cuts off output after X messages we shouldn't add these
by default.
Another option would be categorized logging, but QNAC should not be very
interesting for 'outside' users
Change-Id: I4c2c2a68ca4962476bfecd679f3229ccf3403aee
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Change-Id: Ic7ce41679d89b496413ef13e6e917bf506b2405d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
'oldest' and 'newest' to me make me thing of 'least recently inserted'
and 'most recently inserted', which is what they used to mean.
But now the expiration can be set per-request so the semantics don't
work anymore.
So, rename to 'nextExpiringNode' and 'lastExpiringNode'. Also rename the
node member elements "older" and "newer" to the more generic "previous"
and "next".
Change-Id: I582267d09c60c68396e4201e4a20185bbf0942e2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
There were several issues with the socket state checking when the pipe
reader is not running:
- the number of object handles in the WaitForMultipleObjectsEx()
call might have been zero;
- a call to the waitForDisconnected(-1) might have hung;
- we did not perform a loop iteration for the waitFor...(0) calls,
so disconnect detection was unreliable.
These issues are related to the same code, so they don't seem to be
addressable separately.
Change-Id: I3bca872bb4191e6a7d38a693d81f7981af7fe145
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
The classes themselves were not documented, so...:
Add some documentation for QNetworkAccessBackendFactory.
Add some overall class docs for QNetworkAccessBackend.
The class docs were marked \internal (because they mostly are).
I don't think we yet have a defined way to handle semi-private APIs but
having them be marked \internal and leaving the documentation in source
seems fine (and was what someone suggested a while back).
Add documentation for pure virtual functions which were overlooked.
Pick-to: 6.2
Fixes: QTBUG-88774
Change-Id: Id7fe18ec92372abb96540cd29543608f87ec862e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
When inserting between two nodes the "previous" node's "newer" was
forgotten and not updated. So every node's "newer" would point to the
"newest" node.
Change-Id: I5b0df8812be5f7f62b3ae363e4c78f582e0e5c43
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
The function was never called. As a consequence receiverQueue was
only ever read and never written.
Change-Id: I30905446452d9f263124d3af08c42e2e1b0cafbe
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Rewrite the regex to not capture the things we ignore anyway.
Use capturedView to avoid allocating a string just to turn it into an
int.
Fix a (usually) ifdef-ed out piece of code that was still calling
a QRegExp function.
Make the QRegularExpression static const to save it from having to
recompile every time.
Change-Id: I2f4841a2bc35df4e6cea44aec72432410583f770
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Add the generating of private cpp exports for Qt modules.
Add the GENERATE_PRIVATE_CPP_EXPORTS option to qt_internal_add_module
that is the manual switch for private exports generator. Existing
modules in qtbase doesn't follow any strict convention of using
private cpp export. So there is no clue how to detect if generating of
the private exports is required or not for the module.
Use autogenerated private cpp exports in QtNetwork module.
CPP_EXPORT_HEADER_NAME argument of the qt_internal_add_module function
is replaced by the CPP_EXPORT_HEADER_BASE_NAME and has a different
meaning. The provided name is used as a base name for the private and
non-private headers that contains cpp exports. Header files suffixes
are constant: .h and _p.h for the non-private and private header files
accordingly.
Pick-to: 6.2
Task-number: QTBUG-90492
Change-Id: Icf11304e00379fb8521a865965c19b974e01e62f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
The code was previously calling indexOf() on a temporary, which
QRegularExpression would create backing storage for.
After 11d1dcc6e2 the internals were made
to use the QStringView path, which inadvertently meant that there was
no storage for the temporary string anymore. So we need to keep it alive
ourselves.
Change-Id: I542da7010934594eba3b93261322963866ed9297
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Move all access to the reply inside the nullptr check,
while making sure to still call emscripten_fetch_close()
unconditionally where needed.
Make all four Emscripten callback handlers have a similar
structure where we check if the reply is not null and
not in the Aborted state.
(This removes one emscripten_fetch_t nullptr check in
stateChage(), if it is really the case that Emscripten
calls us with a null emscripten_fetch_t then we should
add it back.)
Pick-to: 5.15 6.1 6.2
Change-Id: Iadcbe6338c338cfeb8967490e0951d8b3e1ec5b3
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
For consistency with naming of other plugins.
Slight compatibility break, but this is semi-private API.
[ChangeLog][Network][QNetworkAccessBackend] The NetworkAccessBackend
plugin-type is renamed to NetworkAccess, if you have a plugin marked
NetworkAccessBackend you need to change it to NetworkAccess.
Pick-to: 6.2
Change-Id: Ib5ea02f542254b0f5b8c425c89ee00075a58c956
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Once per iteration of the loop wouldn't theoretically be so bad if there
was no overhead to emitting signals or reading from buffers.
Change-Id: I0e424264fcc95eb2e2e5f8f908cf9ae3a7cc4b7e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
When the new entry has the same, or older timestamp than the newest,
it's linked behind the newest entry, but "newest" for the new node
currently isn't assigned to the newer entry.
Fixes: QTBUG-95950
Change-Id: I7ef5f1ce5a9479ce47839c8f1a6011124d3f43de
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
To retain backwards compatibility with some QNetworkReply usage,
namely connecting solely to finished-signal and allocating a buffer to
read into, but without storing the entire decompressed file in memory
until read, we may decompress the file twice.
With this patch users can now avoid this double decompression if the
amount of buffered data stays below 10 MiB. This means any file smaller
than 10 MiB will never need to be decompressed twice to know the size of
it. On top of that, if the data is handled as it arrives (e.g. in
readyRead) and the buffer is kept below 10 MiB it won't need to
decompress twice either.
This is active as long as "countDecompressed" is true, though it
currently always is in QNetworkAccessManger, with a future goal to make
it possible to control with public API. Since it requires the user to
potentially adapt their usage of QNetworkReply.
In this patch we also stop tracking the amount of unhandled uncompressed
bytes (uncompressedBytes) in favor of tracking the total amount of bytes
which has been read() by the user of QDecompressHelper (totalBytesRead),
since we can more intuitively work out the total amount of unread bytes
using this value.
Change-Id: Ie3d8d6e39a18343fcf9b610f45c7fe7e4cd4e474
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
The actual buffering is performed either in the inner socket (Unix),
or in the pipeReader (Windows). To avoid unnecessary copying of data
between buffers, enforce unbuffered mode for all implementations,
which slightly improves read performance.
Change-Id: Idb2a09f35823b9945c71231710290be12d9930f7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
This signal is emitted by the QIODevice itself, so we don't have to
forward it from the internal socket.
Pick-to: 6.1 6.2
Change-Id: I85745f36d7a27d92f339a9184de3b6e5d46f6f34
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Before this change, next() was the only way to advance the iterator,
whether the caller was ultimately interested in just the filePath()
(good) or not (bad luck, had to call .fileInfo()).
Add a new function, nextFileInfo(), with returns fileInfo() instead.
Incidentally, the returned object has already been constructed as part
of advance()ing the iterator, so the new function is faster than
next() even if the result is ignored, because we're not calculating a
QString result the caller may not be interested in.
Use the new function around the code.
Fix a couple of cases of next(); fileInfo().filePath() (just use
next()'s return value) as a drive-by.
[ChangeLog][QtCore][QDirIterator] Added nextFileInfo(), which is like
next(), but returns fileInfo() instead of filePath().
Change-Id: I601220575961169b44139fc55b9eae6c3197afb4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Ditto QNetworkAccessAuthenticationManager.
QSharedPointer performs twice as many atomic operations per pointer
copy as std::shared_ptr, and this is private API, we're not bound by
BC constraints, so we can port to the more efficient version.
Change-Id: I59dc09ff4eb3b4acf5d7a68695752a9a7110d8d3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Unix sockets do not suffer from SYN flood, thus the hardcoded value to
50 is size of the only queue to hold connections to be accepted,
resulting in dropped connections when the limit is reached.
On Windows the hardcoded value is 8, this patch changes the default to
50 matching UNIX.
[ChangeLog][QtNetwork][QLocalServer] Added setListenBacklogSize() to
be able to have control over the listen backlog feature.
Change-Id: Iaee6349a46b75b0bd05e40e7ade5948f1cf9f407
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This introduces a new attribute that allows behavior to keep
the TCP connection(s) to a HTTP1/HTTP2 host longer or shorter
than the default of 120 seconds.
Note that the server might still close the connection earlier.
Fixes: QTBUG-20726
Fixes: QTBUG-91440
Change-Id: I7da64230a78c642c12c0ddbe6b678cf17c3aafde
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This mechanism was neither properly designed nor correctly tested
initially on Windows.
[ChangeLog][QtNetwork][Important Behavior Changes] QLocalSocket on
Windows now implements delayed closing, which is consistent with
the behavior on Unix.
Change-Id: Ic3bc427e68eea7f18201f6129df19fbc87d68101
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
It's the user's privilege to do so when they want to finish reading the
QIODevice. Moreover, this is the only difference between close() and
disconnectFromServer().
[ChangeLog][QtNetwork][Important Behavior Changes] The Windows
implementation of QLocalSocket::disconnectFromServer() no longer calls
close(), which is consistent with the behavior on Unix.
Change-Id: Ie9ce20c60259a2b08f5254b719355bd7be9b17cd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>