From d28a96ac7dd6fee9c94874d506fbfb0e75595f02 Mon Sep 17 00:00:00 2001 From: zzz Date: Sun, 9 Sep 2007 17:38:53 +0000 Subject: [PATCH] 2007-09-09 zzz * eepget: Add support for Last-Modified and If-Modified-Since * addressbook: Finish incomplete support for Last-Modified --- .../java/src/addressbook/AddressBook.java | 3 ++- core/java/src/net/i2p/util/EepGet.java | 21 ++++++++++++++++++- history.txt | 6 +++++- .../src/net/i2p/router/RouterVersion.java | 4 ++-- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/apps/addressbook/java/src/addressbook/AddressBook.java b/apps/addressbook/java/src/addressbook/AddressBook.java index b35af4879..db4c33f5b 100644 --- a/apps/addressbook/java/src/addressbook/AddressBook.java +++ b/apps/addressbook/java/src/addressbook/AddressBook.java @@ -92,9 +92,10 @@ public class AddressBook { this.location = subscription.getLocation(); EepGet get = new EepGet(I2PAppContext.getGlobalContext(), true, proxyHost, proxyPort, 0, "addressbook.tmp", - subscription.getLocation(), true, subscription.getEtag()); + subscription.getLocation(), true, subscription.getEtag(), subscription.getLastModified()); get.fetch(); subscription.setEtag(get.getETag()); + subscription.setLastModified(get.getLastModified()); try { this.addresses = ConfigParser.parse(new File("addressbook.tmp")); } catch (IOException exp) { diff --git a/core/java/src/net/i2p/util/EepGet.java b/core/java/src/net/i2p/util/EepGet.java index 71fe4693e..b00decfc1 100644 --- a/core/java/src/net/i2p/util/EepGet.java +++ b/core/java/src/net/i2p/util/EepGet.java @@ -56,6 +56,7 @@ public class EepGet { private long _bytesRemaining; private int _currentAttempt; private String _etag; + private String _lastModified; private boolean _encodingChunked; private boolean _notModified; private String _contentType; @@ -89,9 +90,15 @@ public class EepGet { public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, boolean allowCaching, String etag) { this(ctx, shouldProxy, proxyHost, proxyPort, numRetries, -1, -1, outputFile, null, url, allowCaching, etag, null); } + public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, String outputFile, String url, boolean allowCaching, String etag, String lastModified) { + this(ctx, shouldProxy, proxyHost, proxyPort, numRetries, -1, -1, outputFile, null, url, allowCaching, etag, lastModified, null); + } + public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, long minSize, long maxSize, String outputFile, OutputStream outputStream, String url, boolean allowCaching, String etag, String postData) { + this(ctx, shouldProxy, proxyHost, proxyPort, numRetries, minSize, maxSize, outputFile, outputStream, url, allowCaching, etag, null, postData); + } public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, long minSize, long maxSize, String outputFile, OutputStream outputStream, String url, boolean allowCaching, - String etag, String postData) { + String etag, String lastModified, String postData) { _context = ctx; _log = ctx.logManager().getLog(EepGet.class); _shouldProxy = (proxyHost != null) && (proxyHost.length() > 0) && (proxyPort > 0) && shouldProxy; @@ -115,6 +122,7 @@ public class EepGet { _fetchHeaderTimeout = 30*1000; _listeners = new ArrayList(1); _etag = etag; + _lastModified = lastModified; } /** @@ -730,6 +738,8 @@ public class EepGet { } } else if (key.equalsIgnoreCase("ETag")) { _etag = val.trim(); + } else if (key.equalsIgnoreCase("Last-Modified")) { + _lastModified = val.trim(); } else if (key.equalsIgnoreCase("Transfer-encoding")) { if (val.indexOf("chunked") != -1) _encodingChunked = true; @@ -847,6 +857,11 @@ public class EepGet { buf.append(_etag); buf.append("\r\n"); } + if (_lastModified != null) { + buf.append("If-Modified-Since: "); + buf.append(_lastModified); + buf.append("\r\n"); + } if (post) buf.append("Content-length: ").append(_postData.length()).append("\r\n"); buf.append("Connection: close\r\n\r\n"); @@ -861,6 +876,10 @@ public class EepGet { return _etag; } + public String getLastModified() { + return _lastModified; + } + public boolean getNotModified() { return _notModified; } diff --git a/history.txt b/history.txt index ab2e3cdda..c7b81c4b9 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,8 @@ -$Id: history.txt,v 1.584 2007-08-23 19:33:28 jrandom Exp $ +$Id: history.txt,v 1.585 2007-09-08 15:21:16 zzz Exp $ + +2007-09-09 zzz + * eepget: Add support for Last-Modified and If-Modified-Since + * addressbook: Finish incomplete support for Last-Modified 2007-09-08 zzz * eepget: Copy over SocketTimeout.java file from syndie diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index a7bbcd80e..0a539fade 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -15,9 +15,9 @@ import net.i2p.CoreVersion; * */ public class RouterVersion { - public final static String ID = "$Revision: 1.520 $ $Date: 2007-09-07 21:24:02 $"; + public final static String ID = "$Revision: 1.521 $ $Date: 2007-09-08 15:21:15 $"; public final static String VERSION = "0.6.1.29"; - public final static long BUILD = 2; + public final static long BUILD = 3; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("Router ID: " + RouterVersion.ID);