From ee11696457487f4a68903427fc2b211204c78558 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 11 Mar 2016 19:52:41 +0000 Subject: [PATCH] Fix ETag handling --- source/net/filebot/CachedResource.java | 5 +++-- source/net/filebot/web/WebRequest.java | 4 ---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/source/net/filebot/CachedResource.java b/source/net/filebot/CachedResource.java index 55153695..969b508a 100644 --- a/source/net/filebot/CachedResource.java +++ b/source/net/filebot/CachedResource.java @@ -188,15 +188,16 @@ public class CachedResource implements Resource { try { debug.fine(WebRequest.log(url, lastModified, etagValue)); if (etagValue != null) { - return WebRequest.fetchIfNoneMatch(url, etagValue); + return WebRequest.fetch(url, 0, etagValue, null, responseHeaders); } else { - return WebRequest.fetchIfModified(url, lastModified); + return WebRequest.fetch(url, lastModified, null, null, responseHeaders); } } catch (FileNotFoundException e) { return fileNotFound(url, e); } finally { List value = responseHeaders.get("ETag"); if (value != null && value.size() > 0 && !value.contains(etagValue)) { + debug.finest(format("Store ETag: %s", value)); etagStorage.put(etagKey, value.get(0)); } } diff --git a/source/net/filebot/web/WebRequest.java b/source/net/filebot/web/WebRequest.java index 80051518..d1b17df5 100644 --- a/source/net/filebot/web/WebRequest.java +++ b/source/net/filebot/web/WebRequest.java @@ -110,10 +110,6 @@ public final class WebRequest { return fetch(resource, ifModifiedSince, null, null, null); } - public static ByteBuffer fetchIfNoneMatch(URL resource, Object etag) throws IOException { - return fetch(resource, 0, etag, null, null); - } - public static ByteBuffer fetch(URL url, long ifModifiedSince, Object etag, Map requestParameters, Map> responseParameters) throws IOException { URLConnection connection = url.openConnection();