Skip to content

Commit

Permalink
Clear Sonic cache when Cache-Offline is false
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonlu committed Nov 1, 2017
1 parent af546a8 commit c1e2362
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,11 @@ protected void handleFlow_Connection(String cacheHtml) {
// Handle cache-offline
String cacheOffline = server.getResponseHeaderField(SonicSessionConnection.CUSTOM_HEAD_FILED_CACHE_OFFLINE);
SonicUtils.log(TAG, Log.INFO, "session(" + sId + ") handleFlow_Connection: cacheOffline is " + cacheOffline + ".");
if (TextUtils.isEmpty(cacheOffline) || OFFLINE_MODE_FALSE.equalsIgnoreCase(cacheOffline)) {
SonicUtils.log(TAG, Log.ERROR, "session(" + sId + ") handleFlow_Connection error: Cache-Offline is empty or false!");
SonicUtils.removeSessionCache(id);
return;
}

// When cache-offline is "http": which means sonic server is in bad condition, need feed back to run standard http request.
if (OFFLINE_MODE_HTTP.equalsIgnoreCase(cacheOffline)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,15 @@ protected boolean initConnection(URLConnection connection) {

String eTag = intent.getStringExtra(CUSTOM_HEAD_FILED_ETAG);
if (null == eTag) eTag = "";
connection.setRequestProperty("if-none-match", eTag);
connection.setRequestProperty("If-None-Match", eTag);

String templateTag = intent.getStringExtra(CUSTOM_HEAD_FILED_TEMPLATE_TAG);
if (null == templateTag) templateTag = "";
connection.setRequestProperty(CUSTOM_HEAD_FILED_TEMPLATE_TAG, templateTag);

connection.setRequestProperty("method", "GET");
connection.setRequestProperty("accept-Encoding", "gzip");
connection.setRequestProperty("accept-Language", "zh-CN,zh;");
connection.setRequestProperty("Accept-Encoding", "gzip");
connection.setRequestProperty("Accept-Language", "zh-CN,zh;");
connection.setRequestProperty(CUSTOM_HEAD_FILED_SDK_VERSION, "Sonic/" + SonicConstants.SONIC_VERSION_NUM);

// set custom request headers
Expand Down

0 comments on commit c1e2362

Please sign in to comment.