OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 2 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 4 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
5 * Copyright (C) 2009 Google Inc. All rights reserved. | 5 * Copyright (C) 2009 Google Inc. All rights reserved. |
6 * Copyright (C) 2011 Apple Inc. All Rights Reserved. | 6 * Copyright (C) 2011 Apple Inc. All Rights Reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 static bool isControlCharacter(UChar c) | 741 static bool isControlCharacter(UChar c) |
742 { | 742 { |
743 return c < ' ' || c == 127; | 743 return c < ' ' || c == 127; |
744 } | 744 } |
745 | 745 |
746 static inline String trimToNextSeparator(const String& str) | 746 static inline String trimToNextSeparator(const String& str) |
747 { | 747 { |
748 return str.substring(0, str.find(isCacheHeaderSeparator)); | 748 return str.substring(0, str.find(isCacheHeaderSeparator)); |
749 } | 749 } |
750 | 750 |
751 static void parseCacheHeader(const String& header, Vector<pair<String, String> >
& result) | 751 static void parseCacheHeader(const String& header, Vector<pair<String, String>>&
result) |
752 { | 752 { |
753 const String safeHeader = header.removeCharacters(isControlCharacter); | 753 const String safeHeader = header.removeCharacters(isControlCharacter); |
754 unsigned max = safeHeader.length(); | 754 unsigned max = safeHeader.length(); |
755 for (unsigned pos = 0; pos < max; /* pos incremented in loop */) { | 755 for (unsigned pos = 0; pos < max; /* pos incremented in loop */) { |
756 size_t nextCommaPosition = safeHeader.find(',', pos); | 756 size_t nextCommaPosition = safeHeader.find(',', pos); |
757 size_t nextEqualSignPosition = safeHeader.find('=', pos); | 757 size_t nextEqualSignPosition = safeHeader.find('=', pos); |
758 if (nextEqualSignPosition != kNotFound && (nextEqualSignPosition < nextC
ommaPosition || nextCommaPosition == kNotFound)) { | 758 if (nextEqualSignPosition != kNotFound && (nextEqualSignPosition < nextC
ommaPosition || nextCommaPosition == kNotFound)) { |
759 // Get directive name, parse right hand side of equal sign, then add
to map | 759 // Get directive name, parse right hand side of equal sign, then add
to map |
760 String directive = trimToNextSeparator(safeHeader.substring(pos, nex
tEqualSignPosition - pos).stripWhiteSpace()); | 760 String directive = trimToNextSeparator(safeHeader.substring(pos, nex
tEqualSignPosition - pos).stripWhiteSpace()); |
761 pos += nextEqualSignPosition - pos + 1; | 761 pos += nextEqualSignPosition - pos + 1; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 CacheControlHeader cacheControlHeader; | 809 CacheControlHeader cacheControlHeader; |
810 cacheControlHeader.parsed = true; | 810 cacheControlHeader.parsed = true; |
811 cacheControlHeader.maxAge = std::numeric_limits<double>::quiet_NaN(); | 811 cacheControlHeader.maxAge = std::numeric_limits<double>::quiet_NaN(); |
812 | 812 |
813 DEFINE_STATIC_LOCAL(const AtomicString, noCacheDirective, ("no-cache", Atomi
cString::ConstructFromLiteral)); | 813 DEFINE_STATIC_LOCAL(const AtomicString, noCacheDirective, ("no-cache", Atomi
cString::ConstructFromLiteral)); |
814 DEFINE_STATIC_LOCAL(const AtomicString, noStoreDirective, ("no-store", Atomi
cString::ConstructFromLiteral)); | 814 DEFINE_STATIC_LOCAL(const AtomicString, noStoreDirective, ("no-store", Atomi
cString::ConstructFromLiteral)); |
815 DEFINE_STATIC_LOCAL(const AtomicString, mustRevalidateDirective, ("must-reva
lidate", AtomicString::ConstructFromLiteral)); | 815 DEFINE_STATIC_LOCAL(const AtomicString, mustRevalidateDirective, ("must-reva
lidate", AtomicString::ConstructFromLiteral)); |
816 DEFINE_STATIC_LOCAL(const AtomicString, maxAgeDirective, ("max-age", AtomicS
tring::ConstructFromLiteral)); | 816 DEFINE_STATIC_LOCAL(const AtomicString, maxAgeDirective, ("max-age", AtomicS
tring::ConstructFromLiteral)); |
817 | 817 |
818 if (!cacheControlValue.isEmpty()) { | 818 if (!cacheControlValue.isEmpty()) { |
819 Vector<pair<String, String> > directives; | 819 Vector<pair<String, String>> directives; |
820 parseCacheHeader(cacheControlValue, directives); | 820 parseCacheHeader(cacheControlValue, directives); |
821 | 821 |
822 size_t directivesSize = directives.size(); | 822 size_t directivesSize = directives.size(); |
823 for (size_t i = 0; i < directivesSize; ++i) { | 823 for (size_t i = 0; i < directivesSize; ++i) { |
824 // RFC2616 14.9.1: A no-cache directive with a value is only meaning
ful for proxy caches. | 824 // RFC2616 14.9.1: A no-cache directive with a value is only meaning
ful for proxy caches. |
825 // It should be ignored by a browser level cache. | 825 // It should be ignored by a browser level cache. |
826 if (equalIgnoringCase(directives[i].first, noCacheDirective) && dire
ctives[i].second.isEmpty()) { | 826 if (equalIgnoringCase(directives[i].first, noCacheDirective) && dire
ctives[i].second.isEmpty()) { |
827 cacheControlHeader.containsNoCache = true; | 827 cacheControlHeader.containsNoCache = true; |
828 } else if (equalIgnoringCase(directives[i].first, noStoreDirective))
{ | 828 } else if (equalIgnoringCase(directives[i].first, noStoreDirective))
{ |
829 cacheControlHeader.containsNoStore = true; | 829 cacheControlHeader.containsNoStore = true; |
(...skipping 15 matching lines...) Expand all Loading... |
845 if (!cacheControlHeader.containsNoCache) { | 845 if (!cacheControlHeader.containsNoCache) { |
846 // Handle Pragma: no-cache | 846 // Handle Pragma: no-cache |
847 // This is deprecated and equivalent to Cache-control: no-cache | 847 // This is deprecated and equivalent to Cache-control: no-cache |
848 // Don't bother tokenizing the value, it is not important | 848 // Don't bother tokenizing the value, it is not important |
849 cacheControlHeader.containsNoCache = pragmaValue.lower().contains(noCach
eDirective); | 849 cacheControlHeader.containsNoCache = pragmaValue.lower().contains(noCach
eDirective); |
850 } | 850 } |
851 return cacheControlHeader; | 851 return cacheControlHeader; |
852 } | 852 } |
853 | 853 |
854 } | 854 } |
OLD | NEW |