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

fix network caching code for PreferNetwork

    XMLWordPrintable

Details

    Description

      by applying the following patch and adjusting the tests:

      diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
      index 44afd4d..2d5497f 100644
      --- a/src/network/access/qnetworkaccesshttpbackend.cpp
      +++ b/src/network/access/qnetworkaccesshttpbackend.cpp
      @@ -398,7 +398,10 @@ void QNetworkAccessHttpBackend::validateCache(QHttpNetworkRequest &httpRequest,
           if (lastModified.isValid())
               httpRequest.setHeaderField("If-Modified-Since", QNetworkHeadersPrivate::toHttpDate(lastModified));
       
      -    if (CacheLoadControlAttribute == QNetworkRequest::PreferNetwork) {
      +    if (CacheLoadControlAttribute == QNetworkRequest::PreferNetwork)
      +        return; // PreferNetwork == send the request on the network with a "If-Modified-Since" header, if possible
      +
      +    if (CacheLoadControlAttribute == QNetworkRequest::PreferCache) {
               it = cacheHeaders.findRawHeader("Cache-Control");
               if (it != cacheHeaders.rawHeaders.constEnd()) {
                   QHash<QByteArray, QByteArray> cacheControl = parseHttpOptionHeader(it->second);
      

      Attachments

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

        Activity

          People

            phartman Peter Hartmann (closed Nokia identity) (Inactive)
            phartman Peter Hartmann (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes