mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-20 09:52:13 +01:00
Code reformat
This commit is contained in:
parent
1bc994ec86
commit
f2a4ea5e15
@ -26,15 +26,19 @@ public class CacheControl {
|
||||
Matcher matcher = PATTERN.matcher(value);
|
||||
while (matcher.find()) {
|
||||
switch (matcher.group(1).toLowerCase()) {
|
||||
case "max-age":
|
||||
cc.setMaxAge(Integer.parseInt(matcher.group(3))); break;
|
||||
case "must-revalidate":
|
||||
cc.setMustRevalidate(true); break;
|
||||
case "no-cache":
|
||||
cc.setNoCache(true); break;
|
||||
case "no-store":
|
||||
cc.setNoStore(true); break;
|
||||
default: //ignore
|
||||
case "max-age":
|
||||
cc.setMaxAge(Integer.parseInt(matcher.group(3)));
|
||||
break;
|
||||
case "must-revalidate":
|
||||
cc.setMustRevalidate(true);
|
||||
break;
|
||||
case "no-cache":
|
||||
cc.setNoCache(true);
|
||||
break;
|
||||
case "no-store":
|
||||
cc.setNoStore(true);
|
||||
break;
|
||||
default: //ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,16 +93,16 @@ public class FileDownloaderCache {
|
||||
if (fileCachedOpt.isChange() || !enableCache) {
|
||||
// Update remote etag and cache control header
|
||||
return FileDownloaderCache.updateCacheInfo(remoteURL, (remoteETagClean, cacheControl) -> {
|
||||
// Check cache control data
|
||||
if (cacheControl.isNoCache() || cacheControl.isMustRevalidate() || cacheControl.isNoStore()) {
|
||||
log.warn("The file {} must not be cache due to cache control header {}",
|
||||
remoteURL, cacheControl);
|
||||
return Optional.empty();
|
||||
}
|
||||
// Check cache control data
|
||||
if (cacheControl.isNoCache() || cacheControl.isMustRevalidate() || cacheControl.isNoStore()) {
|
||||
log.warn("The file {} must not be cache due to cache control header {}",
|
||||
remoteURL, cacheControl);
|
||||
return Optional.empty();
|
||||
}
|
||||
fileCachedOpt.setLastETag(remoteETagClean);
|
||||
fileCachedOpt.setCacheControl(cacheControl);
|
||||
return Optional.of(fileCachedOpt);
|
||||
});
|
||||
return Optional.of(fileCachedOpt);
|
||||
});
|
||||
}
|
||||
return Optional.of(fileCachedOpt);
|
||||
}
|
||||
|
@ -67,7 +67,8 @@ public class HttpConnectionManager {
|
||||
|
||||
public HttpURLConnection makeConnection()
|
||||
throws IOException, NoSuchMethodException, ScriptException, URISyntaxException {
|
||||
return makeConnection(this.requestURL, 0, (c) -> {});
|
||||
return makeConnection(this.requestURL, 0, (c) -> {
|
||||
});
|
||||
}
|
||||
|
||||
private HttpURLConnection makeConnection(URL requestURL, int movedTimes,
|
||||
@ -102,7 +103,7 @@ public class HttpConnectionManager {
|
||||
beforeConnection.accept(connection);
|
||||
|
||||
// Connect
|
||||
log.info("Connect to {}, method={}, request id={}", requestURL, connection.getRequestMethod(),requestId);
|
||||
log.info("Connect to {}, method={}, request id={}", requestURL, connection.getRequestMethod(), requestId);
|
||||
|
||||
connection.connect();
|
||||
int resp = connection.getResponseCode();
|
||||
@ -110,7 +111,7 @@ public class HttpConnectionManager {
|
||||
requestURL, connection.getRequestMethod(), resp, requestId, StringUtils.join(connection.getHeaderFields()));
|
||||
|
||||
if (resp == HttpURLConnection.HTTP_MOVED_PERM
|
||||
|| resp == HttpURLConnection.HTTP_MOVED_TEMP) {
|
||||
|| resp == HttpURLConnection.HTTP_MOVED_TEMP) {
|
||||
|
||||
URL newUrl = new URL(connection.getHeaderField("Location"));
|
||||
log.info("The response code was a 301,302 so try again with the new URL " + newUrl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user