Fix no content cache

This commit is contained in:
Alexander Xia committed 2019-02-06 00:39:17 +08:00
1 parent be8b80bd55
commit 7bbfd19bfd
2 files changed
+11 -13

No files matched your search

@@ -138,6 +138,8 @@ public class HttpRequestUtil {
CustomSkinLoader.logger.debug("Successfully request (Response Code: "+c.getResponseCode()+" , Content Length: "+c.getContentLength()+")");
if(responce.responceCode==HttpURLConnection.HTTP_NOT_MODIFIED)
return loadFromCache(request,responce);
if (responce.responceCode == HttpURLConnection.HTTP_NO_CONTENT)
request.cacheTime = 3600;
//Load Content
InputStream is="gzip".equals(c.getContentEncoding())?new GZIPInputStream(c.getInputStream()):c.getInputStream();
@@ -99,23 +99,19 @@ public class MinecraftUtil {
}
}
public static boolean isCoreFile(URL url){
Matcher m;
try{
m=MINECRAFT_CORE_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
}catch(Exception e){
e.printStackTrace();
return false;
}
return m.matches();
public static boolean isCoreFile(URL url) {
return regexMatch(url, MINECRAFT_CORE_FILE_PATTERN);
}
private final static Pattern LIBRARY_FILE_PATTERN = Pattern.compile("^(.*?)/libraries/(.*?)/([^\\/\\\\]*?).jar$");
public static boolean isLibraryFile(URL url){
public static boolean isLibraryFile(URL url) {
return regexMatch(url, LIBRARY_FILE_PATTERN);
}
private static boolean regexMatch(URL url, Pattern p) {
Matcher m;
try{
m=LIBRARY_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
}catch(Exception e){
try {
m=p.matcher(URLDecoder.decode(url.getPath(), "UTF-8"));
} catch (Exception e) {
e.printStackTrace();
return false;
}