Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0a17f45e authored by Henrik Baard's avatar Henrik Baard Committed by Steve Kondik
Browse files

Error in compound cache-control header.

A cache control header containing both no-cache and max-age attribute does not
behave as expected.

Cache-Control: no-cache, max-age=200000

Will set expired to 20000ms seconds, ignoring the no-cache header. My
interpretation is that the no-cache header should not be ignored in
this case.

Change-Id: Iadd1900e4d2c6c0dacc6bb3e7b944cf78ca9b266
parent 88fa082a
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -752,6 +752,7 @@ public final class CacheManager {
        String cacheControl = headers.getCacheControl();
        String cacheControl = headers.getCacheControl();
        if (cacheControl != null) {
        if (cacheControl != null) {
            String[] controls = cacheControl.toLowerCase().split("[ ,;]");
            String[] controls = cacheControl.toLowerCase().split("[ ,;]");
            boolean noCache = false;
            for (int i = 0; i < controls.length; i++) {
            for (int i = 0; i < controls.length; i++) {
                if (NO_STORE.equals(controls[i])) {
                if (NO_STORE.equals(controls[i])) {
                    return null;
                    return null;
@@ -762,7 +763,8 @@ public final class CacheManager {
                // can only be used in CACHE_MODE_CACHE_ONLY case
                // can only be used in CACHE_MODE_CACHE_ONLY case
                if (NO_CACHE.equals(controls[i])) {
                if (NO_CACHE.equals(controls[i])) {
                    ret.expires = 0;
                    ret.expires = 0;
                } else if (controls[i].startsWith(MAX_AGE)) {
                    noCache = true;
                } else if (controls[i].startsWith(MAX_AGE) && !noCache) {
                    int separator = controls[i].indexOf('=');
                    int separator = controls[i].indexOf('=');
                    if (separator < 0) {
                    if (separator < 0) {
                        separator = controls[i].indexOf(':');
                        separator = controls[i].indexOf(':');