diff --git a/core/java/src/net/i2p/util/EepGet.java b/core/java/src/net/i2p/util/EepGet.java index 2805ea5f09a78c6faeef5ed072563f300bb2166b..2198486cc6d9d5d7dbd0cac91349672d26f57a85 100644 --- a/core/java/src/net/i2p/util/EepGet.java +++ b/core/java/src/net/i2p/util/EepGet.java @@ -8,6 +8,7 @@ import java.io.InputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; import java.io.OutputStream; +import java.net.ConnectException; import java.net.MalformedURLException; import java.net.Socket; import java.net.URL; @@ -64,6 +65,8 @@ public class EepGet { protected boolean _shouldWriteErrorToOutput; protected String _etag; protected String _lastModified; + protected final String _etagOrig; + protected final String _lastModifiedOrig; protected boolean _encodingChunked; protected boolean _notModified; protected String _contentType; @@ -142,6 +145,8 @@ public class EepGet { _listeners = new ArrayList(1); _etag = etag; _lastModified = lastModified; + _etagOrig = etag; + _lastModifiedOrig = lastModified; } /** @@ -524,7 +529,8 @@ public class EepGet { _listeners.get(i).attemptFailed(_url, _bytesTransferred, _bytesRemaining, _currentAttempt, _numRetries, ioe); if (_log.shouldLog(Log.WARN)) _log.warn("ERR: doFetch failed ", ioe); - if (ioe instanceof MalformedURLException) + if (ioe instanceof MalformedURLException || + ioe instanceof ConnectException) // proxy or nonproxied host Connection Refused _keepFetching = false; } finally { if (_out != null) { @@ -610,8 +616,8 @@ public class EepGet { // reset some important variables, we don't want to save the values from the redirect _bytesRemaining = -1; _redirectLocation = null; - _etag = null; - _lastModified = null; + _etag = _etagOrig; + _lastModified = _lastModifiedOrig; _contentType = null; _encodingChunked = false; @@ -724,8 +730,13 @@ public class EepGet { if (_transferFailed) { // 404, etc - transferFailed is called after all attempts fail, by fetch() above - for (int i = 0; i < _listeners.size(); i++) - _listeners.get(i).attemptFailed(_url, _bytesTransferred, _bytesRemaining, _currentAttempt, _numRetries, new Exception("Attempt failed")); + if (!_listeners.isEmpty()) { + Exception e = new IOException("Attempt failed " + _responseCode); + for (int i = 0; i < _listeners.size(); i++) { + _listeners.get(i).attemptFailed(_url, _bytesTransferred, _bytesRemaining, _currentAttempt, + _numRetries, e); + } + } } else if ((_minSize > 0) && (_alreadyTransferred < _minSize)) { throw new IOException("Bytes transferred " + _alreadyTransferred + " violates minimum of " + _minSize + " bytes"); } else if ( (_bytesRemaining == -1) || (remaining == 0) ) { diff --git a/core/java/src/net/i2p/util/SocketTimeout.java b/core/java/src/net/i2p/util/SocketTimeout.java index e5c02d5c9713e2cf96f83d895814c5650aa329fd..f506d4de36c4fa0fb4b734ca7d8c09317115306c 100644 --- a/core/java/src/net/i2p/util/SocketTimeout.java +++ b/core/java/src/net/i2p/util/SocketTimeout.java @@ -7,7 +7,7 @@ import java.util.Date; /** * This should be deprecated. - * It is only used by EepGet. + * It is only used by EepGet and Syndie. * The only advantage seems to be a total timeout period, which is the second * argument to EepGet.fetch(headerTimeout, totalTimeout, inactivityTimeout), * which is most likely always set to -1. @@ -52,6 +52,11 @@ public class SocketTimeout extends SimpleTimer2.TimedEvent { } } + /** + * Change in return value from void to boolean in + * 0.9.3 accidentally broke Syndie, sorry. + * Recompile Syndie to fix it. + */ public boolean cancel() { _cancelled = true; return super.cancel(); diff --git a/router/java/src/net/i2p/router/util/RFC822Date.java b/router/java/src/net/i2p/router/util/RFC822Date.java index 2ae4d45696355d73bfc980188421d2adea1ce120..a61e86ef7729147ac35b3a55bc5fe2dedaa2b2a0 100644 --- a/router/java/src/net/i2p/router/util/RFC822Date.java +++ b/router/java/src/net/i2p/router/util/RFC822Date.java @@ -4,6 +4,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; +import java.util.TimeZone; /** * Moved from NewsFetcher @@ -13,7 +14,7 @@ public abstract class RFC822Date { // SimpleDateFormat is not thread-safe, methods must be synchronized - private static final SimpleDateFormat OUTPUT_FORMAT = new SimpleDateFormat("d MMM yyyy HH:mm:ss z", Locale.US); + private static final SimpleDateFormat OUTPUT_FORMAT = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z", Locale.US); /** * http://jimyjoshi.com/blog/2007/08/rfc822dateparsinginjava.html @@ -22,7 +23,7 @@ public abstract class RFC822Date { */ private static final SimpleDateFormat rfc822DateFormats[] = new SimpleDateFormat[] { OUTPUT_FORMAT, - new SimpleDateFormat("EEE, d MMM yy HH:mm:ss z", Locale.US), + new SimpleDateFormat("d MMM yy HH:mm:ss z", Locale.US), new SimpleDateFormat("EEE, d MMM yy HH:mm z", Locale.US), new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z", Locale.US), new SimpleDateFormat("EEE, d MMM yyyy HH:mm z", Locale.US), @@ -31,6 +32,16 @@ public abstract class RFC822Date { new SimpleDateFormat("d MMM yyyy HH:mm z", Locale.US) }; + // + // The router JVM is forced to UTC but do this just in case + // + static { + TimeZone utc = TimeZone.getTimeZone("GMT"); + for (int i = 0; i < rfc822DateFormats.length; i++) { + rfc822DateFormats[i].setTimeZone(utc); + } + } + /** * new Date(String foo) is deprecated, so let's do this the hard way * @@ -56,4 +67,18 @@ public abstract class RFC822Date { public synchronized static String to822Date(long t) { return OUTPUT_FORMAT.format(new Date(t)); } + +/**** + public static void main(String[] args) { + if (args.length == 1) { + try { + System.out.println(to822Date(Long.parseLong(args[0]))); + } catch (NumberFormatException nfe) { + System.out.println(nfe.toString()); + } + } else { + System.out.println("Usage: RFC822Date numericDate"); + } + } +****/ }