2007-09-09 zzz

* eepget: Add support for Last-Modified and If-Modified-Since
    * addressbook: Finish incomplete support for Last-Modified
This commit is contained in:
zzz
2007-09-09 17:38:53 +00:00
committed by zzz
parent 9c73f80ac3
commit d28a96ac7d
4 changed files with 29 additions and 5 deletions

View File

@ -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) {

View File

@ -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;
}

View File

@ -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

View File

@ -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);