* Reseed: Send If-Modified-Since in fetches

* EepGet: Fixes for adding etag or lastmod headers before fetch
This commit is contained in:
zzz
2014-07-05 18:41:09 +00:00
parent e0c0cc8b63
commit 4e463d57ce
2 changed files with 40 additions and 17 deletions

View File

@@ -575,7 +575,6 @@ public class Reseeder {
/** @return null on error */
private byte[] readURL(URL url) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream(4*1024);
EepGet get;
boolean ssl = url.toString().startsWith("https");
if (ssl) {
@@ -603,6 +602,10 @@ public class Reseeder {
get.addAuthorization(user, pass);
}
}
if (!url.toString().endsWith("/")) {
String minLastMod = RFC822Date.to822Date(_context.clock().now() - MAX_FILE_AGE);
get.addHeader("If-Modified-Since", minLastMod);
}
get.addStatusListener(ReseedRunner.this);
if (get.fetch() && get.getStatusCode() == 200)
return baos.toByteArray();
@@ -644,6 +647,10 @@ public class Reseeder {
get.addAuthorization(user, pass);
}
}
if (!url.toString().endsWith("/")) {
String minLastMod = RFC822Date.to822Date(_context.clock().now() - MAX_FILE_AGE);
get.addHeader("If-Modified-Since", minLastMod);
}
get.addStatusListener(ReseedRunner.this);
if (get.fetch() && get.getStatusCode() == 200)
return out;