Changeset 183407 in webkit


Ignore:
Timestamp:
Apr 27, 2015 11:57:13 AM (9 years ago)
Author:
peavo@outlook.com
Message:

[Curl] Favicons loaded from disc cache are ignored.
https://bugs.webkit.org/show_bug.cgi?id=143953

Reviewed by Alex Christensen.

When a favicon is loaded from the Curl disc cache, the icon data is thrown away.
This happens because we give a 304 response, which makes the icon loader ignore
the response. We can solve this by responding with 200 OK.

  • platform/network/ResourceHandleInternal.h:

(WebCore::ResourceHandleInternal::ResourceHandleInternal):

  • platform/network/curl/CurlCacheManager.cpp:

(WebCore::CurlCacheManager::didReceiveResponse):

  • platform/network/curl/ResourceHandleManager.cpp:

(WebCore::headerCallback):
(WebCore::ResourceHandleManager::initializeHandle):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r183405 r183407  
     12015-04-27  Per Arne Vollan  <peavo@outlook.com>
     2
     3        [Curl] Favicons loaded from disc cache are ignored.
     4        https://bugs.webkit.org/show_bug.cgi?id=143953
     5
     6        Reviewed by Alex Christensen.
     7
     8        When a favicon is loaded from the Curl disc cache, the icon data is thrown away.
     9        This happens because we give a 304 response, which makes the icon loader ignore
     10        the response. We can solve this by responding with 200 OK.
     11
     12        * platform/network/ResourceHandleInternal.h:
     13        (WebCore::ResourceHandleInternal::ResourceHandleInternal):
     14        * platform/network/curl/CurlCacheManager.cpp:
     15        (WebCore::CurlCacheManager::didReceiveResponse):
     16        * platform/network/curl/ResourceHandleManager.cpp:
     17        (WebCore::headerCallback):
     18        (WebCore::ResourceHandleManager::initializeHandle):
     19
    1202015-04-27  Brady Eidson  <beidson@apple.com>
    221
  • trunk/Source/WebCore/platform/network/ResourceHandleInternal.h

    r183265 r183407  
    8888#endif
    8989#if USE(CURL)
    90             , m_handle(0)
    91             , m_url(0)
    92             , m_customHeaders(0)
    93             , m_cancelled(false)
    94             , m_authFailureCount(0)
    9590            , m_formDataStream(loader)
    96             , m_sslErrors(0)
    9791#endif
    9892#if USE(SOUP)
     
    152146#endif
    153147#if USE(CURL)
    154         CURL* m_handle;
    155         char* m_url;
    156         struct curl_slist* m_customHeaders;
     148        CURL* m_handle { nullptr };
     149        char* m_url { nullptr };
     150        struct curl_slist* m_customHeaders { nullptr };
    157151        ResourceResponse m_response;
    158         bool m_cancelled;
    159         unsigned short m_authFailureCount;
     152        bool m_cancelled { false };
     153        unsigned short m_authFailureCount { 0 };
    160154
    161155        FormDataStream m_formDataStream;
    162         unsigned m_sslErrors;
     156        unsigned m_sslErrors { 0 };
    163157        Vector<char> m_postBytes;
    164158
    165159        std::unique_ptr<MultipartHandle> m_multipartHandle;
     160        bool m_addedCacheValidationHeaders { false };
    166161#endif
    167162#if USE(SOUP)
  • trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp

    r177080 r183407  
    207207    removeCacheEntryClient(url, &job);
    208208
    209     if (response.httpStatusCode() == 304) {
     209    if (response.source() == ResourceResponseBase::Source::DiskCache) {
    210210        readCachedData(url, &job, response);
    211211        m_LRUEntryList.prependOrMoveToFirst(url);
  • trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp

    r183265 r183407  
    554554            if (isHttpNotModified(httpCode)) {
    555555                const String& url = job->firstRequest().url().string();
    556                 CurlCacheManager::getInstance().getCachedResponse(url, d->m_response);
     556                if (CurlCacheManager::getInstance().getCachedResponse(url, d->m_response)) {
     557                    if (d->m_addedCacheValidationHeaders) {
     558                        d->m_response.setHTTPStatusCode(200);
     559                        d->m_response.setHTTPStatusText("OK");
     560                    }
     561                }
    557562            }
    558563            client->didReceiveResponse(job, d->m_response);
     
    10861091        HTTPHeaderMap customHeaders = job->firstRequest().httpHeaderFields();
    10871092
    1088         if (CurlCacheManager::getInstance().isCached(url)) {
     1093        bool hasCacheHeaders = customHeaders.contains(HTTPHeaderName::IfModifiedSince) || customHeaders.contains(HTTPHeaderName::IfNoneMatch);
     1094        if (!hasCacheHeaders && CurlCacheManager::getInstance().isCached(url)) {
    10891095            CurlCacheManager::getInstance().addCacheEntryClient(url, job);
    10901096            HTTPHeaderMap& requestHeaders = CurlCacheManager::getInstance().requestHeaders(url);
     
    10971103                ++it;
    10981104            }
    1099         } else {
    1100             // Make sure we don't send any cache headers when url is not cached.
    1101             customHeaders.remove(HTTPHeaderName::IfModifiedSince);
    1102             customHeaders.remove(HTTPHeaderName::IfNoneMatch);
     1105            d->m_addedCacheValidationHeaders = true;
    11031106        }
    11041107
Note: See TracChangeset for help on using the changeset viewer.