Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-60230

QNetworkAccessManager with QNetworkRequest::PreferCache fails if network not present

    XMLWordPrintable

Details

    Description

      If:

      • a cache is specified for QNetworkAccessManager and
      • PreferCache is specified using QNetworkRequest's method setAttribute called like
        setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache) and
      • the network/internet connection is not present

      then, the request will still fail when called from a RichText QML Text with

      QML QQuickText: Network access is disabled.

      However, if you modify the setAttribute call to use QNetworkRequest::AlwaysCache when the network isn't present, then it will work:

      cacheRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute,
          (networkAccessible() == QNetworkAccessManager::Accessible ?
              QNetworkRequest::PreferCache :
              QNetworkRequest::AlwaysCache));

      I would like to suggest that this is a bug, because if you say you would PreferCache, you don't want it to fail if you have a valid cache entry, but the network isn't present.

      For more code context, see this StackOverflow answer by jpnurmi

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cnn Qt Core & Network
            ross.rogers Ross Rogers
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes