Changeset 184690 in webkit


Ignore:
Timestamp:
May 20, 2015 7:09:14 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

Enable disk cache for range requests
https://bugs.webkit.org/show_bug.cgi?id=144682

Patch by Marcos Chavarría Teijeiro <mchavarria@igalia.com> on 2015-05-20
Reviewed by Antti Koivisto.

Source/WebKit2:

Add Range header value to the network cache key constructor so we take
into account this value. The 206 response code is also marked to be cached.

  • NetworkProcess/cache/NetworkCache.cpp:

(WebKit::NetworkCache::makeCacheKey):
(WebKit::NetworkCache::isStatusCodeCacheableByDefault):

  • NetworkProcess/cache/NetworkCacheKey.cpp:

(WebKit::NetworkCache::Key::Key):
(WebKit::NetworkCache::Key::operator=):
(WebKit::NetworkCache::Key::computeHash):
(WebKit::NetworkCache::Key::operator==):
(WebKit::NetworkCache::Key::encode):
(WebKit::NetworkCache::Key::decode):
(WebKit::NetworkCache::Key::stringToHash): Deleted.

  • NetworkProcess/cache/NetworkCacheKey.h:

LayoutTests:

  • http/tests/cache/disk-cache/disk-cache-range-expected.txt: Added. Add Test.
  • http/tests/cache/disk-cache/disk-cache-range.html: Added.
  • http/tests/cache/disk-cache/resources/generate-response.cgi: Modify script to return 206 and 416 response codes if Range header is present.
  • platform/gtk/TestExpectations: Remove failing test.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r184676 r184690  
     12015-05-20  Marcos Chavarría Teijeiro  <mchavarria@igalia.com>
     2
     3        Enable disk cache for range requests
     4        https://bugs.webkit.org/show_bug.cgi?id=144682
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * http/tests/cache/disk-cache/disk-cache-range-expected.txt: Added. Add Test.
     9        * http/tests/cache/disk-cache/disk-cache-range.html: Added.
     10        * http/tests/cache/disk-cache/resources/generate-response.cgi: Modify script to return 206 and 416 response codes if Range header is present.
     11        * platform/gtk/TestExpectations: Remove failing test.
     12
    1132015-05-20  Chris Fleizach  <cfleizach@apple.com>
    214
  • trunk/LayoutTests/http/tests/cache/disk-cache/resources/generate-response.cgi

    r182157 r184690  
    2020}
    2121
     22if ($query->http && $query->param("Range") =~ /bytes=(\d+)-(\d+)/) {
     23
     24    if ($1 < 6 && $2 < 6) {
     25        print "Status: 206\n";
     26    } else {
     27        print "Status: 416\n";
     28    }
     29
     30    $hasStatusCode = 1;
     31}
     32
    2233foreach (@names) {
    2334    next if ($_ eq "uniqueId");
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r184561 r184690  
    22932293webkit.org/b/144763 fast/events/scroll-in-scaled-page-with-overflow-hidden.html
    22942294
    2295 webkit.org/b/144682 http/tests/xmlhttprequest/range-test.html [ Failure ]
    2296 
    22972295webkit.org/b/141835 media/video-controls-no-scripting.html [ Failure ]
    22982296webkit.org/b/145048 http/tests/misc/bad-charset-alias.html [ Failure ]
  • trunk/Source/WebKit2/ChangeLog

    r184686 r184690  
     12015-05-20  Marcos Chavarría Teijeiro  <mchavarria@igalia.com>
     2
     3        Enable disk cache for range requests
     4        https://bugs.webkit.org/show_bug.cgi?id=144682
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Add Range header value to the network cache key constructor so we take
     9        into account this value. The 206 response code is also marked to be cached.
     10
     11        * NetworkProcess/cache/NetworkCache.cpp:
     12        (WebKit::NetworkCache::makeCacheKey):
     13        (WebKit::NetworkCache::isStatusCodeCacheableByDefault):
     14        * NetworkProcess/cache/NetworkCacheKey.cpp:
     15        (WebKit::NetworkCache::Key::Key):
     16        (WebKit::NetworkCache::Key::operator=):
     17        (WebKit::NetworkCache::Key::computeHash):
     18        (WebKit::NetworkCache::Key::operator==):
     19        (WebKit::NetworkCache::Key::encode):
     20        (WebKit::NetworkCache::Key::decode):
     21        (WebKit::NetworkCache::Key::stringToHash): Deleted.
     22        * NetworkProcess/cache/NetworkCacheKey.h:
     23
    1242015-05-20  Anders Carlsson  <andersca@apple.com>
    225
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp

    r184620 r184690  
    110110    if (partition.isEmpty())
    111111        partition = ASCIILiteral("No partition");
    112     return { request.httpMethod(), partition, request.url().string()  };
     112
     113    // FIXME: This implements minimal Range header disk cache support. We don't parse
     114    // ranges so only the same exact range request will be served from the cache.
     115    String range = request.httpHeaderField(WebCore::HTTPHeaderName::Range);
     116    return { request.httpMethod(), partition, range, request.url().string()  };
    113117}
    114118
     
    238242    case 203: // Non-Authoritative Information
    239243    case 204: // No Content
     244    case 206: // Partial Content
    240245    case 300: // Multiple Choices
    241246    case 301: // Moved Permanently
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.cpp

    r182432 r184690  
    4141    , m_partition(o.m_partition.isolatedCopy())
    4242    , m_identifier(o.m_identifier.isolatedCopy())
     43    , m_range(o.m_range.isolatedCopy())
    4344    , m_hash(o.m_hash)
    4445{
    4546}
    4647
    47 Key::Key(const String& method, const String& partition, const String& identifier)
     48Key::Key(const String& method, const String& partition, const String& range, const String& identifier)
    4849    : m_method(method.isolatedCopy())
    4950    , m_partition(partition.isolatedCopy())
    5051    , m_identifier(identifier.isolatedCopy())
     52    , m_range(range.isolatedCopy())
    5153    , m_hash(computeHash())
    5254{
     
    5860    m_partition = other.m_partition.isolatedCopy();
    5961    m_identifier = other.m_identifier.isolatedCopy();
     62    m_range = other.m_range.isolatedCopy();
    6063    m_hash = other.m_hash;
    6164    return *this;
     
    6568{
    6669    const uint8_t zero = 0;
     70
     71    if (string.isNull())
     72        return;
     73
    6774    if (string.is8Bit() && string.containsOnlyASCII()) {
    6875        md5.addBytes(string.characters8(), string.length());
     
    8390    hashString(md5, m_partition);
    8491    hashString(md5, m_identifier);
     92    hashString(md5, m_range);
    8593    MD5::Digest hash;
    8694    md5.checksum(hash);
     
    122130bool Key::operator==(const Key& other) const
    123131{
    124     return m_hash == other.m_hash && m_method == other.m_method && m_partition == other.m_partition && m_identifier == other.m_identifier;
     132    return m_hash == other.m_hash && m_method == other.m_method && m_partition == other.m_partition && m_identifier == other.m_identifier && m_range == other.m_range;
    125133}
    126134
     
    130138    encoder << m_partition;
    131139    encoder << m_identifier;
     140    encoder << m_range;
    132141    encoder << m_hash;
    133142}
     
    135144bool Key::decode(Decoder& decoder, Key& key)
    136145{
    137     return decoder.decode(key.m_method) && decoder.decode(key.m_partition) && decoder.decode(key.m_identifier) && decoder.decode(key.m_hash);
     146    return decoder.decode(key.m_method) && decoder.decode(key.m_partition) && decoder.decode(key.m_identifier) && decoder.decode(key.m_range) && decoder.decode(key.m_hash);
    138147}
    139148
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.h

    r182432 r184690  
    4545    Key(const Key&);
    4646    Key(Key&&) = default;
    47     Key(const String& method, const String& partition, const String& identifier);
     47    Key(const String& method, const String& partition, const String& range, const String& identifier);
    4848
    4949    Key& operator=(const Key&);
     
    7575    String m_partition;
    7676    String m_identifier;
     77    String m_range;
    7778    HashType m_hash;
    7879};
Note: See TracChangeset for help on using the changeset viewer.