Don't re-append the query string to the redirect URL,

which caused eepget to repeatedly retry the new redirect
of an i2paddresshelper query by the HTTP proxy.

This was clearly non-compliant (the Location: header requires
an absolute URI including any query string).

This was part of the original redirect handling added by
jrandom to eepget back when it was in syndie;
appending that changelog just in case this hackery was
required by Freenet USKs, which I doubt.

Also, reset the redirect counter when retrying.

==============

	Revision: 62a8cac8565958d111d0a47a443c964918d2e3ef
	Parent:   277fe109ea4416f7d8a6dba6e09cd4f605a8ce1a
	Author:   jrandom@i2p.net
	Date:     10/22/2006 15:06:30
	Branch:   i2p.syndie

	Changelog: 
	    ...
	    - add support for HTTP 301 redirects to EepGet (so freenet USKs work as
	      intended)
This commit is contained in:
zzz
2011-05-27 21:41:49 +00:00
parent 0000e4f28d
commit 393d813d05
4 changed files with 15 additions and 19 deletions

View File

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

View File

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

View File

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

View File

@ -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 = "";