From 09d1eb17d49e15b1aae2becbc9f8d60434496f73 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Wed, 6 Oct 2010 01:11:21 +0000 Subject: [PATCH] reset eepget length variable after a redirect --- core/java/src/net/i2p/util/EepGet.java | 9 +++++++++ core/java/src/net/i2p/util/EepHead.java | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/core/java/src/net/i2p/util/EepGet.java b/core/java/src/net/i2p/util/EepGet.java index 3fec768a58..ace31ab720 100644 --- a/core/java/src/net/i2p/util/EepGet.java +++ b/core/java/src/net/i2p/util/EepGet.java @@ -537,6 +537,15 @@ public class EepGet { if (_redirects > 5) throw new IOException("Too many redirects: to " + _redirectLocation); if (_log.shouldLog(Log.INFO)) _log.info("Redirecting to " + _redirectLocation); + + // reset some important variables, we don't want to save the values from the redirect + _bytesRemaining = -1; + _redirectLocation = null; + _etag = null; + _lastModified = null; + _contentType = null; + _encodingChunked = false; + sendRequest(timeout); doFetch(timeout); return; diff --git a/core/java/src/net/i2p/util/EepHead.java b/core/java/src/net/i2p/util/EepHead.java index 938241616a..c3a17bbea5 100644 --- a/core/java/src/net/i2p/util/EepHead.java +++ b/core/java/src/net/i2p/util/EepHead.java @@ -116,6 +116,7 @@ public class EepHead extends EepGet { else timeout.setInactivityTimeout(60*1000); + // Should we even follow redirects for HEAD? if (_redirectLocation != null) { //try { URL oldURL = new URL(_actualURL); @@ -143,6 +144,15 @@ public class EepHead extends EepGet { if (_redirects > 5) throw new IOException("Too many redirects: to " + _redirectLocation); if (_log.shouldLog(Log.INFO)) _log.info("Redirecting to " + _redirectLocation); + + // reset some important variables, we don't want to save the values from the redirect + _bytesRemaining = -1; + _redirectLocation = null; + _etag = null; + _lastModified = null; + _contentType = null; + _encodingChunked = false; + sendRequest(timeout); doFetch(timeout); return; -- GitLab