diff --git a/core/java/src/net/i2p/util/EepGet.java b/core/java/src/net/i2p/util/EepGet.java index 955ae8238dec3df9e54e2212fb2d87cfcaa0e241..45622a002aede3f83bcacb0e9bc7877d743df5e5 100644 --- a/core/java/src/net/i2p/util/EepGet.java +++ b/core/java/src/net/i2p/util/EepGet.java @@ -474,6 +474,7 @@ public class EepGet { (_alreadyTransferred == 0 && _currentAttempt > MAX_COMPLETE_FAILS) || !_keepFetching) break; + _redirects = 0; try { long delay = _context.random().nextInt(60*1000); Thread.sleep(5*1000+delay); @@ -512,22 +513,18 @@ public class EepGet { if (_redirectLocation != null) { //try { - URL oldURL = new URL(_actualURL); - String query = oldURL.getQuery(); - if (query == null) query = ""; if (_redirectLocation.startsWith("http://")) { - if ( (_redirectLocation.indexOf('?') < 0) && (query.length() > 0) ) - _actualURL = _redirectLocation + "?" + query; - else - _actualURL = _redirectLocation; + _actualURL = _redirectLocation; } else { + // the Location: field has been required to be an absolute URI at least since + // RFC 1945 (HTTP/1.0 1996), so it isn't clear what the point of this is. + // This oddly adds a ":" even if no port, but that seems to work. URL url = new URL(_actualURL); if (_redirectLocation.startsWith("/")) _actualURL = "http://" + url.getHost() + ":" + url.getPort() + _redirectLocation; else + // this blows up completely on a redirect to https://, for example _actualURL = "http://" + url.getHost() + ":" + url.getPort() + "/" + _redirectLocation; - if ( (_actualURL.indexOf('?') < 0) && (query.length() > 0) ) - _actualURL = _actualURL + "?" + query; } // an MUE is an IOE //} catch (MalformedURLException mue) { diff --git a/core/java/src/net/i2p/util/EepHead.java b/core/java/src/net/i2p/util/EepHead.java index bb8304a3963a04b0d739c28f6efcd9ea5a7adfb5..c4850e8c616c1e1a544045cda62cee25a30272d1 100644 --- a/core/java/src/net/i2p/util/EepHead.java +++ b/core/java/src/net/i2p/util/EepHead.java @@ -121,22 +121,18 @@ public class EepHead extends EepGet { // Should we even follow redirects for HEAD? if (_redirectLocation != null) { //try { - URL oldURL = new URL(_actualURL); - String query = oldURL.getQuery(); - if (query == null) query = ""; if (_redirectLocation.startsWith("http://")) { - if ( (_redirectLocation.indexOf('?') < 0) && (query.length() > 0) ) - _actualURL = _redirectLocation + "?" + query; - else - _actualURL = _redirectLocation; + _actualURL = _redirectLocation; } else { + // the Location: field has been required to be an absolute URI at least since + // RFC 1945 (HTTP/1.0 1996), so it isn't clear what the point of this is. + // This oddly adds a ":" even if no port, but that seems to work. URL url = new URL(_actualURL); if (_redirectLocation.startsWith("/")) _actualURL = "http://" + url.getHost() + ":" + url.getPort() + _redirectLocation; else + // this blows up completely on a redirect to https://, for example _actualURL = "http://" + url.getHost() + ":" + url.getPort() + "/" + _redirectLocation; - if ( (_actualURL.indexOf('?') < 0) && (query.length() > 0) ) - _actualURL = _actualURL + "?" + query; } // an MUE is an IOE //} catch (MalformedURLException mue) { diff --git a/history.txt b/history.txt index a62c93347cd3045d338595041f6e0d164e99edea..31218b9627a980220e804dd260d7bc2985eab47a 100644 --- a/history.txt +++ b/history.txt @@ -2,6 +2,9 @@ * Console: Fix router.updateThroughProxy being set to false after saving change on /configupdate when install dir is read-only. (ticket #466) + * EepGet: + - Fix redirect loop (thx kytv) + - Reset redirect counter when retrying * JBigI: - Refactor to handle 64 bit libs and a list of fallback libs - Logging tweaks diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index f2522cd4ed540000a936a603d4922f4a287ece1f..7ca1a3ec2c4e6b0a58a1f89cf73e6cb3036dcf84 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 9; + public final static long BUILD = 10; /** for example "-test" */ public final static String EXTRA = "";