mirror of
https://gitlab.com/oeffi/oeffi.git
synced 2025-07-08 15:08:47 +00:00
Downloader: Use Headers.getDate() rather than parsing the date manually.
This commit is contained in:
parent
759afdd5ca
commit
93e4e23f60
1 changed files with 6 additions and 10 deletions
|
@ -50,7 +50,6 @@ import okhttp3.HttpUrl;
|
|||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import okhttp3.internal.http.HttpDate;
|
||||
|
||||
public class Downloader {
|
||||
private final File cacheDir;
|
||||
|
@ -84,15 +83,12 @@ public class Downloader {
|
|||
final Request.Builder request = new Request.Builder();
|
||||
request.url(remoteUrl);
|
||||
if (meta != null) {
|
||||
final String expiresHeader = meta.get("Expires");
|
||||
if (expiresHeader != null) {
|
||||
final Date expires = HttpDate.parse(expiresHeader);
|
||||
if (expires != null && System.currentTimeMillis() < expires.getTime()) {
|
||||
log.info("Download '{}' skipped; using cached copy.", remoteUrl);
|
||||
future.set(HttpURLConnection.HTTP_NOT_MODIFIED);
|
||||
semaphore.release();
|
||||
return future;
|
||||
}
|
||||
final Date expires = meta.getDate("Expires");
|
||||
if (expires != null && System.currentTimeMillis() < expires.getTime()) {
|
||||
log.info("Download '{}' skipped; using cached copy.", remoteUrl);
|
||||
future.set(HttpURLConnection.HTTP_NOT_MODIFIED);
|
||||
semaphore.release();
|
||||
return future;
|
||||
}
|
||||
|
||||
final String lastModified = meta.get("Last-Modified");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue