aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/android/volley/toolbox
diff options
context:
space:
mode:
authorDave Santoro <dsantoro@google.com>2015-03-10 18:28:03 -0700
committerDave Santoro <dsantoro@google.com>2015-03-11 13:57:17 -0700
commit782b52fd6f5c62f5b38148432acbc4e79351fd0b (patch)
treebb20152d00e23305d2989afd5888a73474cfc7db /src/main/java/com/android/volley/toolbox
parent815797fab585958b6031093fe03ff281f953f2fa (diff)
downloadvolley-782b52fd6f5c62f5b38148432acbc4e79351fd0b.tar.gz
Modify header parser to handle must-revalidate.
This flag indicates that the response must NOT be returned after the cache TTL has expired, but it does not mandate that the response should not be cached at all (which the code was doing previously). Change-Id: I61532f3aa8144c50dcee442dc30215bb81ada868
Diffstat (limited to 'src/main/java/com/android/volley/toolbox')
-rw-r--r--src/main/java/com/android/volley/toolbox/HttpHeaderParser.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main/java/com/android/volley/toolbox/HttpHeaderParser.java b/src/main/java/com/android/volley/toolbox/HttpHeaderParser.java
index 7306052..c3b48d8 100644
--- a/src/main/java/com/android/volley/toolbox/HttpHeaderParser.java
+++ b/src/main/java/com/android/volley/toolbox/HttpHeaderParser.java
@@ -49,6 +49,7 @@ public class HttpHeaderParser {
long maxAge = 0;
long staleWhileRevalidate = 0;
boolean hasCacheControl = false;
+ boolean mustRevalidate = false;
String serverEtag = null;
String headerValue;
@@ -77,7 +78,7 @@ public class HttpHeaderParser {
} catch (Exception e) {
}
} else if (token.equals("must-revalidate") || token.equals("proxy-revalidate")) {
- maxAge = 0;
+ mustRevalidate = true;
}
}
}
@@ -98,7 +99,9 @@ public class HttpHeaderParser {
// is more restrictive.
if (hasCacheControl) {
softExpire = now + maxAge * 1000;
- finalExpire = softExpire + staleWhileRevalidate * 1000;
+ finalExpire = mustRevalidate
+ ? softExpire
+ : softExpire + staleWhileRevalidate * 1000;
} else if (serverDate > 0 && serverExpires >= serverDate) {
// Default semantic for Expire header in HTTP specification is softExpire.
softExpire = now + (serverExpires - serverDate);