mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-13 20:44:02 +00:00
Add forceDisableCache
This commit is contained in:
4 files changed
+17
-11
No files matched your search
@@ -7,6 +7,7 @@ import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
@@ -26,7 +27,11 @@ public class HttpRequestUtil {
|
||||
public boolean loadContent = true;
|
||||
public boolean checkPNG = false;
|
||||
|
||||
public int cacheTime = 600;//-1=No Cache 0=Always Cache t=Default Cache Time(second)
|
||||
/**
|
||||
* Cache Time
|
||||
* -1=No Cache 0=Always Cache t=Default Cache Time(second)
|
||||
*/
|
||||
public int cacheTime = 600;
|
||||
public File cacheFile = null;//Default Cache File
|
||||
|
||||
public HttpRequest(String url) {
|
||||
@@ -93,8 +98,9 @@ public class HttpRequestUtil {
|
||||
}
|
||||
CustomSkinLoader.logger.debug("Try to request '" + request.url + (request.userAgent == null ? "'." : "' with user agent '" + request.userAgent + "'."));
|
||||
//Check Cache
|
||||
if (StringUtils.isNotEmpty(request.payload))
|
||||
if (StringUtils.isNotEmpty(request.payload) || CustomSkinLoader.config.forceDisableCache){
|
||||
request.cacheTime = -1;//No Cache
|
||||
}
|
||||
File cacheInfoFile = null;
|
||||
CacheInfo cacheInfo = new CacheInfo();
|
||||
if (request.cacheFile == null && request.cacheTime >= 0) {
|
||||
@@ -203,7 +209,7 @@ public class HttpRequestUtil {
|
||||
}
|
||||
if (!request.loadContent)
|
||||
return responce;
|
||||
responce.content = new String(bytes, "UTF-8");
|
||||
responce.content = new String(bytes, StandardCharsets.UTF_8);
|
||||
CustomSkinLoader.logger.debug("Content: " + responce.content);
|
||||
return responce;
|
||||
|
||||
@@ -254,7 +260,6 @@ public class HttpRequestUtil {
|
||||
long expires = connection.getExpiration();
|
||||
if (expires > 0)
|
||||
return expires / 1000;
|
||||
return TimeUtil.getUnixTimestampRandomDelay(cacheTime == 0 ? 86400 : cacheTime);
|
||||
|
||||
return TimeUtil.getUnixTimestampRandomDelay(cacheTime == 0 ? 2592000 : cacheTime);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user