summaryrefslogtreecommitdiffstats
path: root/src/network/access
Commit message (Collapse)AuthorAgeFilesLines
...
* Functions for setting request transfer timeoutsJuha Vuolle2023-12-085-0/+63
| | | | | | | | | | Added to both QNetworkRequestFactory and QRestAccessManager Task-number: QTBUG-114717 Change-Id: Ibca55bba548a034a0da7ea60550642c150b63dc2 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Support for std::chrono as transferTimeout typeJuha Vuolle2023-12-086-26/+99
| | | | | | | | | | | | | | | | | | | | Provide users with means to use more modern time/duration type. Please note that since QTimer does not currently support timeouts larger than 'int' milliseconds, the limit on how long durations can be expressed, remains. This should not be an issue in practice with network requests, as a typical int32 system can express timeouts of ~24 days. [ChangeLog][QtNetwork][QNetworkAccessManager] Add std::chrono support for transfer timeout. [ChangeLog][QtNetwork][QNetworkRequest] Add std::chrono support for transfer timeout. Fixes: QTBUG-118714 Change-Id: If85678a5994c59bac5926e47f98c9cfeb2a07c30 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Add uploadProgress signal for QRestReplyJuha Vuolle2023-12-082-1/+23
| | | | | | | Task-number: QTBUG-114717 Change-Id: I2052e4cc4da90962483f5f1931dc20552e484e34 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add signals and methods for QRestReply download progressJuha Vuolle2023-12-082-1/+50
| | | | | | | | | | | | These include: - readyRead(), signal for indicating new data availability - bytesAvailable(), function for checking available data amount - downloadProgress(), signal for monitoring download progress Task-number: QTBUG-114717 Change-Id: Id6c49530d7857f5c76bd111eba84525137294ea7 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add REST client convenience wrappersJuha Vuolle2023-12-086-0/+1474
| | | | | | | | | | | | | [ChangeLog][QtNetwork][QRestAccessManager] Added new convenience classes QRestAccessManager and QRestReply for typical RESTful client application usage Task-number: QTBUG-114637 Task-number: QTBUG-114701 Change-Id: I65057e56bf27f365b54bfd528565efd5f09386aa Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QNetworkRequestFactory convenience classJuha Vuolle2023-12-083-0/+622
| | | | | | | | | | | | | | | | | | | | | The class provides a way to represent server-side service endpoints. With RESTful applications these endpoints typically have a need for repeating requests fields such as headers, query parameters, bearer token, base URL, SSL configuration. This class allows setting of the repeating parts, while allowing the setting of changing parts on a per-request basis. [ChangeLog][QtNetwork][QNetworkRequestFactory] Added a new convenience class to help with the needs of repeating network request details imposed by the server-side service endpoints, which is common with RESTful applications. Task-number: QTBUG-113814 Change-Id: Iabcfaed786949ffbb0ad0c75297d0db6ecc1a3cc Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add QHttpHeaders classJuha Vuolle2023-12-082-0/+1380
| | | | | | | | | | | | New QHttpHeaders class for use in place of std::pair<QBA,QBA>, QMap<QBA>, and QMultiMap/Hash<QBA,QBA> to represent HTTP headers. [ChangeLog][QtNetwork][QHttpHeaders] New QHttpHeaders class Task-number: QTBUG-107042 Change-Id: I54766886a491acfc9a813a3414322a75011acb9d Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* wasm: Proxy emscripten_fetch() to the main threadPiotr Wierciński2023-11-221-1/+5
| | | | | | | | | | | | | | Calling emscripten_fetch() on worker thread which never yields control back to the browser, will leave the fetch request pending forever. This can be a problematic for example in QML Loader, which tries to load resource by network. Proxy this function call to the main thread, so it can be processed by the browser. Fixes: QTBUG-118225 Pick-to: 6.6 6.5 Change-Id: I969d73f6a66670c4135960e08d2eedc8d2a6e5c3 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* http2: Fix authentication code and raceMårten Nordheim2023-11-152-57/+78
| | | | | | | | | | | | By attempting to get credentials and potentially emitting error during header parsing we may not have gotten the DATA frames yet which would leave us emitting error() and finished() without any body. Pick-to: 6.6 6.5 6.2 Change-Id: Ibc5fb78193af80ddabaca2c9e4149bbcac9789a1 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QNonContiguousByteDeviceThreadForwardImpl: reset m_atEnd during reset()Mårten Nordheim2023-11-061-0/+1
| | | | | | | | | | | Because otherwise the atEnd() function will return true if we finished an upload, and then we reset due to an error and try to upload again. In a future patch we rely on atEnd() returning true only if the data has actually been consumed, so re-uploads will not work correctly. Pick-to: 6.6 6.5 Change-Id: Id914648f2509dd112b6bfc71231caa59cbe8ae68 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Http: simplify check for preconnect requestMårten Nordheim2023-11-062-4/+2
| | | | | Change-Id: I132533b9bc1f2b4d66f94599efb04def571cd2ff Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* qhttpnetworkreply: remove unused findChallenge methodAnton Kudryavtsev2023-11-032-17/+0
| | | | | | | This method is part of private API, so it's safe. Change-Id: Idc7464a825841db2fa9dddd47d6dbda82668601d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qnetworkcookie: remove parseCookiesAnton Kudryavtsev2023-11-022-9/+3
| | | | | | | that takes QBA in favor of QBAV version Change-Id: I56bbe5cc5c7fa3e31e6b6e71d97211de3eb1ab26 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qhttpnetworkreply: use QBAV moreAnton Kudryavtsev2023-11-011-4/+4
| | | | | | | to reduce allocations Change-Id: I89879a68626631970d34bbc0357528dcbb8b1c17 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qhttpnetworkreply_p: port parseStatus and parseHeader to QBAVAnton Kudryavtsev2023-11-012-6/+6
| | | | | Change-Id: Ib3bb2d29460827f9dfceb51975ce822d8a41aba0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QNetworkReplyHttpImplPrivate: de-duplicate literalsAnton Kudryavtsev2023-11-011-3/+5
| | | | | | | While touching code, use CaseInsensitive compare more to avoid needless tmp allocation Change-Id: I4fe8496133925887df6879b48c730c36f486fa9c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* network: use CIS compare moreAnton Kudryavtsev2023-11-011-8/+7
| | | | | | | to reduce allocations Change-Id: I648518fd152a834bbdc6afcedb693f02c1b13af1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QHttp2ProtocolHandler: optimize updateStreamAnton Kudryavtsev2023-11-011-5/+3
| | | | | | | Use QBAV more to reduce allocations Change-Id: I009144156fafa64dd241c446bd4081fe197aa2bf Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qnetworkcookiejar: optimize validateCookieAnton Kudryavtsev2023-10-301-2/+3
| | | | | | | Use string view more to reduce allocations Change-Id: Ib73fb9607438c7da115406f61653641163370122 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qnetworkcookiejar::deleteCookie: port raw loop to algorithmAnton Kudryavtsev2023-10-301-6/+5
| | | | | | | Use std::find_if with const iterators to avoid unconditional detach Change-Id: Ibc9d05586a1926fefba5c6fd73c5b15ee815cd6d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qnetworkcookiejar: optimize cookiesForUrlAnton Kudryavtsev2023-10-301-27/+16
| | | | | | | | | Check cheap conditions first. Use string view types more Don't insert in the middle of list, just append and then sort Change-Id: I1ad7c3459eab45b2289bfe044314eec7130d8153 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QHttpNetworkConnection: use QSB moreAnton Kudryavtsev2023-10-301-1/+1
| | | | | | | to avoid needless tmp allocation Change-Id: I582f86adbe274b67ddbc7255caea63a39137edcc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QHttpNetworkConnection: mark some methods as constAnton Kudryavtsev2023-10-302-6/+6
| | | | | | | | These get methods (sslContext and connectionType) are part of private API, so it's safe Change-Id: I6c2e14d5dbcbefc051d69985d1e9b490274ba7ef Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qnetworkcookiejar: port internal functions to QSVAnton Kudryavtsev2023-10-301-3/+3
| | | | | Change-Id: I2f377ca63b2d376736fa8adff88c47616939dd23 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qhttpmultipart: use range-for moreAnton Kudryavtsev2023-10-301-4/+3
| | | | | | | to improve readability Change-Id: I9b7cad485c354b58b1acee7cea159988bf37c9df Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qnetworkrequest, qnetworkreply: port some methods to QBAVAnton Kudryavtsev2023-10-305-13/+25
| | | | | | | | | [ChangeLog][QtNetwork] Ported hasRawHeader and rawHeader of QNetworkReply and QNetworkRequest to QByteArrayView. Change-Id: Ife71ba11b1ee8907c104dba3210d7a033568edf4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Make QHttpNetworkConnectionPrivate::parseRedirectResponse staticMårten Nordheim2023-10-181-1/+1
| | | | | | | | We will use it without holding an instance later. And there's no reason it is not static already. Change-Id: I06d455bb2852244c8a4993ea75ceda4e1cb679fb Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Support body for an HTTP GET requestMate Barany2023-10-173-3/+55
| | | | | | | | | | | | | | | | | | | | | | Add two overloads to QNetworkAccessManager to support GET requests with body. Modify QNetworkReplyHttpImpl as well as these requests should not be cached. If the request is redirected it is possible that its type changes from POST/PUT to GET and in this case the message body is deleted. However, if a GET request has a body it should keep it after it has been redirected - modify QNetworkReplyHttpImpl to keep the message body after it has been redirected. Fixes: QTBUG-112871 Change-Id: Ib01898638ed94238a98291870a5c51d56030868a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* Network: Use the new invokeMethod overloadMårten Nordheim2023-10-171-1/+1
| | | | | | | Saves us from having to create a lambda functor object. Change-Id: I5e790e693b57ae414ac6d6be84f18b76b3e8185c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* http2: When a reply is removed from the queue, only remove oneMårten Nordheim2023-10-161-11/+10
| | | | | | | | | | | | | | | | | | We were using the .remove(Key) API on the map instead of erase(iterator), so we were removing any reply of the same priority that had not yet been popped from the queues. Rewrote to drop loop and only work with iterators. This issue was there since SPDY days, so not picking all the way back to 5.15, where HTTP2 anyway is not enabled by default. As a drive-by, drop the #ifndef QT_NO_SSL, which was also there from SPDY times, which was TLS-only. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-116167 Change-Id: Id7e1eb311e009b86054c1fe3d049c760d711a18a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QNonContigByteDeviceThreadForwardImpl: NSDMIMårten Nordheim2023-10-131-11/+7
| | | | | | | | | Makes it clearer what members depend on arguments to the ctor. And what the initial value of all the members are. Change-Id: Ie1cd2361955053eaf4c4e6887d23ac245738288d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mate Barany <mate.barany@qt.io>
* Http: don't try to send request on a closed socketMårten Nordheim2023-10-131-0/+5
| | | | | | | | | | | | We have code in the protocolHandlers that tries to handle this case, but if we have an error before we create protocolHandler (read: proxy complains about something) we will assert in debug, or deref nullptr in release. Pick-to: 6.6 6.5 6.2 Change-Id: I4bde9c8af0fa96dc11f77ca4d4b5cb84c31b54fa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Include what you need: <QPointer>Marc Mutz2023-10-123-0/+5
| | | | | | | | | | | | | | | | | | | | | | | All these TUs relied on transitive includes of qpointer.h, maybe to a large extent via qevent.h, though, given that qevent.h is more or less the only public QtBase header that includes qpointer.h, something else seems to be at play here. Said qevent.h actually needs QPointer in-name-only, so a forward declaration would suffice. Prepare for qevent.h dropping the include. The algorithm I used was: If the TU mentions 'passiveGrabbers', the name of the QEvent function that returns QPointers, and the TU doesn't have qpointer.h included explicitly, include it. That may produce False Positives, but better safe than sorry. Otherwise, in src/, add an include to all source and header files which mention QPointer. Exception: if foo.h of a foo.cpp already includes it, don't include again. Task-number: QTBUG-117670 Change-Id: I3321cccdb41ce0ba6d8a709cea92427aba398254 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Fix link to renamed setIncludesSubDomains() methodKai Köhne2023-10-091-2/+2
| | | | | | | | | | Fix capitalization of setIncludesSubDomains(). While a it, make the links explicit, so that qdoc generates warnings if they fail. Pick-to: 6.5 6.6 Change-Id: I74542c288083ec58f866a616da32bd40fcb3f40a Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QHttpThreadDelegate: use new(std::nothrow) instead of try..catchMårten Nordheim2023-10-071-8/+5
| | | | | | | | | | | We usually compile without exceptions, so the try..catch is a noop. So, if the `new` fails we would crash (or get UB) anyway. Instead of that, use the nothrow version of `new` and check the result. Pick-to: 6.6 6.5 Change-Id: I1902b717c70afcc44c1f3237370aae346262452a Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* http: fix leakage of network cache qiodeviceMårten Nordheim2023-10-061-1/+1
| | | | | | | | | | | | | The QIODevice is owned by the caller of data(), so we should have freed it. Amends a6776de0c70d23ac197682c7bef603450cb8b03f Fixes: QTBUG-117787 Pick-to: 6.6 6.5 6.2 Change-Id: Ic5575649038480f52cc13ee229980ee1c7cee728 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Mate Barany <mate.barany@qt.io>
* QHttp2ProtocolHandler: reduce allocationsAnton Kudryavtsev2023-09-251-11/+21
| | | | | | | | Don't use QMap for parsing. Indroduce local enum and use it with std::array Change-Id: I60fed6991ac415e4ff3827ae621f2c9b5071dcbe Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* qnetworkreplyhttpimpl: use QBAV moreAnton Kudryavtsev2023-09-251-5/+7
| | | | | Change-Id: Ieee68c06962da7c12af2b4145495b3d5ba5a02fb Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QHttp2ProtocolHandler: extract methodAnton Kudryavtsev2023-09-251-10/+19
| | | | | | | | for making url to improve readability Change-Id: I743f183b64f2ed9c9363ea4fd2bdb8588fd84547 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Tidy up QNetworkDiskCache::prepareAnton Kudryavtsev2023-09-121-5/+1
| | | | | | | | use std::nothrow more Change-Id: I7c681089777e86a31db2fba831362771e6607496 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QHttpNetworkConnectionChannel: reduce allocationsAnton Kudryavtsev2023-09-071-24/+22
| | | | | | | | | | - don't use QMap::values, just iterate over QMap directly - use const methods to avoid implicit detatch While touching code, use isEmpty() to check container instead of size() with 0 Change-Id: I300b5f123f339dc92a4f932bd0b356f31ead3589 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* network: use string view types moreAnton Kudryavtsev2023-09-062-2/+2
| | | | | | | Prefer QLatin1StringView overloads Change-Id: I23846761f2c93021de4f6e6b7eba1d74045f89a1 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QNetworkReply: fix potential nullptr access in loadFromCacheIfAllowed()Vladimir Belyavsky2023-09-061-1/+2
| | | | | | | | | | | | | | | Fix a potential nullptr access in QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed() on accessing to QAbstractNetworkCache::data(). It is not yet clear in what cases cached data can be null, especially if metaData is present, but we have user reports of such crashes. Amends a6776de0c70d23ac197682c7bef603450cb8b03f Fixes: QTBUG-116788 Pick-to: 6.2 6.5 6.6 Change-Id: I548065c6f809d9d45db6dd785c28acbdc77621e2 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Remove redundant QPair includesAhmad Samir2023-09-061-1/+0
| | | | | | | | Nothing in those files uses QPair; and a local build finished fine without them. Task-number: QTBUG-115841 Change-Id: I669cfecaa9129bce6b31e464826287f138b159db Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDecompressHelper: uncache acceptedEncodingAnton Kudryavtsev2023-09-051-9/+6
| | | | | | | The only user already has its own cache of transformed copy of acceptedEncoding list since 43d15dd57235835a26977c227f90753c2fc196e4 Change-Id: I485b41555f327c6ff39dd48347240a725f00e09b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QNetworkAccessCacheBackend: reduce allocationsAnton Kudryavtsev2023-09-051-4/+6
| | | | | | | Use CaseInsensitive compare more. Change-Id: I2f6d19fd63ac2e06c5b0dcb285a578f9ed61c6ab Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qhttpnetworkconnection: extract method makeAcceptLanguageAnton Kudryavtsev2023-09-041-11/+13
| | | | | | | | | and micro optimize it: - avoid allocation in case of C locale - don't call replace in case of C locale Change-Id: I9afefd53b673e5f1236afdb3130d77779614acc7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qhttpnetworkconnection: cache acceptedEncoding headerAnton Kudryavtsev2023-09-041-2/+2
| | | | | | | Encodings are configured at compile time, so no need to re-create acceptedEncoding header for every request, just cache it. Change-Id: Ibfaf7cdec0504cf90c4b6a59848e7c945d060ebe Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDecompressHelper: port some methods to QBAVAnton Kudryavtsev2023-09-042-9/+9
| | | | | Change-Id: I907019f19cbf4f6086fd6480ea9e01f5ab63b004 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qnetworkcookie: reduce allocationsAnton Kudryavtsev2023-09-041-10/+14
| | | | | | | | | Use CaseInsensitive compare more. While touching code, replcace QBA literal with QBAV Change-Id: Iecd2740c995f1e24b4285440b9440e4745f93208 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>