Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: third_party/WebKit/Source/platform/network/HTTPParsers.cpp

Issue 2767853003: Remove stale-while-revalidate from blink (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/network/HTTPParsers.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 } 693 }
694 } 694 }
695 } 695 }
696 696
697 CacheControlHeader parseCacheControlDirectives( 697 CacheControlHeader parseCacheControlDirectives(
698 const AtomicString& cacheControlValue, 698 const AtomicString& cacheControlValue,
699 const AtomicString& pragmaValue) { 699 const AtomicString& pragmaValue) {
700 CacheControlHeader cacheControlHeader; 700 CacheControlHeader cacheControlHeader;
701 cacheControlHeader.parsed = true; 701 cacheControlHeader.parsed = true;
702 cacheControlHeader.maxAge = std::numeric_limits<double>::quiet_NaN(); 702 cacheControlHeader.maxAge = std::numeric_limits<double>::quiet_NaN();
703 cacheControlHeader.staleWhileRevalidate =
704 std::numeric_limits<double>::quiet_NaN();
705 703
706 static const char noCacheDirective[] = "no-cache"; 704 static const char noCacheDirective[] = "no-cache";
707 static const char noStoreDirective[] = "no-store"; 705 static const char noStoreDirective[] = "no-store";
708 static const char mustRevalidateDirective[] = "must-revalidate"; 706 static const char mustRevalidateDirective[] = "must-revalidate";
709 static const char maxAgeDirective[] = "max-age"; 707 static const char maxAgeDirective[] = "max-age";
710 static const char staleWhileRevalidateDirective[] = "stale-while-revalidate";
711 708
712 if (!cacheControlValue.isEmpty()) { 709 if (!cacheControlValue.isEmpty()) {
713 Vector<std::pair<String, String>> directives; 710 Vector<std::pair<String, String>> directives;
714 parseCacheHeader(cacheControlValue, directives); 711 parseCacheHeader(cacheControlValue, directives);
715 712
716 size_t directivesSize = directives.size(); 713 size_t directivesSize = directives.size();
717 for (size_t i = 0; i < directivesSize; ++i) { 714 for (size_t i = 0; i < directivesSize; ++i) {
718 // RFC2616 14.9.1: A no-cache directive with a value is only meaningful 715 // RFC2616 14.9.1: A no-cache directive with a value is only meaningful
719 // for proxy caches. It should be ignored by a browser level cache. 716 // for proxy caches. It should be ignored by a browser level cache.
720 if (equalIgnoringCase(directives[i].first, noCacheDirective) && 717 if (equalIgnoringCase(directives[i].first, noCacheDirective) &&
721 directives[i].second.isEmpty()) { 718 directives[i].second.isEmpty()) {
722 cacheControlHeader.containsNoCache = true; 719 cacheControlHeader.containsNoCache = true;
723 } else if (equalIgnoringCase(directives[i].first, noStoreDirective)) { 720 } else if (equalIgnoringCase(directives[i].first, noStoreDirective)) {
724 cacheControlHeader.containsNoStore = true; 721 cacheControlHeader.containsNoStore = true;
725 } else if (equalIgnoringCase(directives[i].first, 722 } else if (equalIgnoringCase(directives[i].first,
726 mustRevalidateDirective)) { 723 mustRevalidateDirective)) {
727 cacheControlHeader.containsMustRevalidate = true; 724 cacheControlHeader.containsMustRevalidate = true;
728 } else if (equalIgnoringCase(directives[i].first, maxAgeDirective)) { 725 } else if (equalIgnoringCase(directives[i].first, maxAgeDirective)) {
729 if (!std::isnan(cacheControlHeader.maxAge)) { 726 if (!std::isnan(cacheControlHeader.maxAge)) {
730 // First max-age directive wins if there are multiple ones. 727 // First max-age directive wins if there are multiple ones.
731 continue; 728 continue;
732 } 729 }
733 bool ok; 730 bool ok;
734 double maxAge = directives[i].second.toDouble(&ok); 731 double maxAge = directives[i].second.toDouble(&ok);
735 if (ok) 732 if (ok)
736 cacheControlHeader.maxAge = maxAge; 733 cacheControlHeader.maxAge = maxAge;
737 } else if (equalIgnoringCase(directives[i].first,
738 staleWhileRevalidateDirective)) {
739 if (!std::isnan(cacheControlHeader.staleWhileRevalidate)) {
740 // First stale-while-revalidate directive wins if there are multiple
741 // ones.
742 continue;
743 }
744 bool ok;
745 double staleWhileRevalidate = directives[i].second.toDouble(&ok);
746 if (ok)
747 cacheControlHeader.staleWhileRevalidate = staleWhileRevalidate;
748 } 734 }
749 } 735 }
750 } 736 }
751 737
752 if (!cacheControlHeader.containsNoCache) { 738 if (!cacheControlHeader.containsNoCache) {
753 // Handle Pragma: no-cache 739 // Handle Pragma: no-cache
754 // This is deprecated and equivalent to Cache-control: no-cache 740 // This is deprecated and equivalent to Cache-control: no-cache
755 // Don't bother tokenizing the value, it is not important 741 // Don't bother tokenizing the value, it is not important
756 cacheControlHeader.containsNoCache = 742 cacheControlHeader.containsNoCache =
757 pragmaValue.lower().contains(noCacheDirective); 743 pragmaValue.lower().contains(noCacheDirective);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 bool parseContentRangeHeaderFor206(const String& contentRange, 865 bool parseContentRangeHeaderFor206(const String& contentRange,
880 int64_t* firstBytePosition, 866 int64_t* firstBytePosition,
881 int64_t* lastBytePosition, 867 int64_t* lastBytePosition,
882 int64_t* instanceLength) { 868 int64_t* instanceLength) {
883 return net::HttpUtil::ParseContentRangeHeaderFor206( 869 return net::HttpUtil::ParseContentRangeHeaderFor206(
884 StringUTF8Adaptor(contentRange).asStringPiece(), firstBytePosition, 870 StringUTF8Adaptor(contentRange).asStringPiece(), firstBytePosition,
885 lastBytePosition, instanceLength); 871 lastBytePosition, instanceLength);
886 } 872 }
887 873
888 } // namespace blink 874 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/network/HTTPParsers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698