Changeset 120339 in webkit


Ignore:
Timestamp:
Jun 14, 2012 10:42:18 AM (12 years ago)
Author:
ap@apple.com
Message:

[CFNetwork] XMLHttpRequest incorrectly returns cached responses even when there is a Vary header field
https://bugs.webkit.org/show_bug.cgi?id=88925

Reviewed by David Kilzer.

Test: http/tests/cache/xhr-vary-header.html

  • platform/network/cf/ResourceHandleCFNet.cpp: (WebCore::willCacheResponse): Don't cache the response at all if there is a Vary header field. CFNetwork won't look at it if we allowed the response cached.
  • platform/network/mac/ResourceHandleMac.mm: (WebCore::ResourceHandle::createNSURLConnection): [NSURLResponse copy] is mutable in practice, but we should be nice, and use -mutableCopy. (-[WebCoreResourceHandleAsDelegate connection:willCacheResponse:]): Same fix as in CFNet code.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r120334 r120339  
     12012-06-14  Alexey Proskuryakov  <ap@apple.com>
     2
     3        [CFNetwork] XMLHttpRequest incorrectly returns cached responses even when there is a Vary header field
     4        https://bugs.webkit.org/show_bug.cgi?id=88925
     5
     6        Reviewed by David Kilzer.
     7
     8        * http/tests/cache/resources/xhr-vary-header-response.php: Added.
     9        * http/tests/cache/resources/xhr-vary-header-subframe.html: Added.
     10        * http/tests/cache/xhr-vary-header-expected.txt: Added.
     11        * http/tests/cache/xhr-vary-header.html: Added.
     12
    1132012-06-14  Simon Pena  <spena@igalia.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r120338 r120339  
     12012-06-14  Alexey Proskuryakov  <ap@apple.com>
     2
     3        [CFNetwork] XMLHttpRequest incorrectly returns cached responses even when there is a Vary header field
     4        https://bugs.webkit.org/show_bug.cgi?id=88925
     5
     6        Reviewed by David Kilzer.
     7
     8        Test: http/tests/cache/xhr-vary-header.html
     9
     10        * platform/network/cf/ResourceHandleCFNet.cpp: (WebCore::willCacheResponse): Don't
     11        cache the response at all if there is a Vary header field. CFNetwork won't look at
     12        it if we allowed the response cached.
     13
     14        * platform/network/mac/ResourceHandleMac.mm:
     15        (WebCore::ResourceHandle::createNSURLConnection): [NSURLResponse copy] is mutable
     16        in practice, but we should be nice, and use -mutableCopy.
     17        (-[WebCoreResourceHandleAsDelegate connection:willCacheResponse:]): Same fix as in
     18        CFNet code.
     19
    1202012-06-13  Andrey Kosyakov  <caseq@chromium.org>
    221
  • trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp

    r109670 r120339  
    318318{
    319319    ResourceHandle* handle = static_cast<ResourceHandle*>(const_cast<void*>(clientInfo));
     320    CFURLResponseRef wrappedResponse = CFCachedURLResponseGetWrappedResponse(cachedResponse);
     321
     322    // Workaround for <rdar://problem/6300990> Caching does not respect Vary HTTP header.
     323    // FIXME: WebCore cache has issues with Vary, too (bug 58797, bug 71509).
     324    if (CFHTTPMessageRef httpResponse = CFURLResponseGetHTTPResponse(wrappedResponse)) {
     325        ASSERT(CFHTTPMessageIsHeaderComplete(httpResponse));
     326        RetainPtr<CFStringRef> varyValue = adoptCF(CFHTTPMessageCopyHeaderFieldValue(httpResponse, CFSTR("Vary")));
     327        if (varyValue)
     328            return 0;
     329    }
    320330
    321331#if PLATFORM(WIN)
     
    337347        RetainPtr<CFArrayRef> receiverData(AdoptCF, CFCachedURLResponseCopyReceiverDataArray(cachedResponse));
    338348        cachedResponse = CFCachedURLResponseCreateWithDataArray(kCFAllocatorDefault,
    339                                                                 CFCachedURLResponseGetWrappedResponse(cachedResponse),
     349                                                                wrappedResponse,
    340350                                                                receiverData.get(),
    341351                                                                CFCachedURLResponseGetUserInfo(cachedResponse),
     
    343353#else
    344354        cachedResponse = CFCachedURLResponseCreateWithUserInfo(kCFAllocatorDefault,
    345                                                                CFCachedURLResponseGetWrappedResponse(cachedResponse),
     355                                                               wrappedResponse,
    346356                                                               CFCachedURLResponseGetReceiverData(cachedResponse),
    347357                                                               CFCachedURLResponseGetUserInfo(cachedResponse),
  • trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm

    r112162 r120339  
    210210    NSURLRequest *nsRequest = firstRequest().nsURLRequest();
    211211    if (!shouldContentSniff) {
    212         NSMutableURLRequest *mutableRequest = [[nsRequest copy] autorelease];
     212        NSMutableURLRequest *mutableRequest = [[nsRequest mutableCopy] autorelease];
    213213        wkSetNSURLRequestShouldContentSniff(mutableRequest, NO);
    214214        nsRequest = mutableRequest;
     
    888888        return nil;
    889889
     890    // Workaround for <rdar://problem/6300990> Caching does not respect Vary HTTP header.
     891    // FIXME: WebCore cache has issues with Vary, too (bug 58797, bug 71509).
     892    if ([[cachedResponse response] isKindOfClass:[NSHTTPURLResponse class]]
     893        && [[(NSHTTPURLResponse *)[cachedResponse response] allHeaderFields] objectForKey:@"Vary"])
     894        return nil;
     895
    890896    NSCachedURLResponse *newResponse = m_handle->client()->willCacheResponse(m_handle, cachedResponse);
    891897    if (newResponse != cachedResponse)
Note: See TracChangeset for help on using the changeset viewer.