# HG changeset patch
# User Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
# Date 1702634716 -3600
# Node ID aad275e042b2e2391b894dced289398942d8f921
# Parent  071be9a628e83e2812b249dbee74006d15072200
Heed followRedirect

diff --git a/src/main/java/org/monetdb/mcl/net/MapiSocket.java b/src/main/java/org/monetdb/mcl/net/MapiSocket.java
--- a/src/main/java/org/monetdb/mcl/net/MapiSocket.java
+++ b/src/main/java/org/monetdb/mcl/net/MapiSocket.java
@@ -112,7 +112,12 @@ public final class MapiSocket {
 	/** protocol version of the connection */
 	private int version;
 
-	/** Whether we should follow redirects */
+	/** Whether we should follow redirects.
+	 * Not sure why this needs to be separate
+	 * from 'ttl' but someone someday explicitly documented setTtl
+	 * with 'to disable completely, use followRedirects' so
+	 * apparently there is a use case.
+	 */
 	private boolean followRedirects = true;
 	/** How many redirections do we follow until we're fed up with it? */
 	private int ttl = 10;
@@ -316,7 +321,7 @@ public final class MapiSocket {
 				if (!ok)
 					close();
 			}
-		} while (attempts++ < this.ttl);
+		} while (followRedirects && attempts++ < this.ttl);
 		throw new MCLException("max redirect count exceeded");
 	}