public static InetAddress originAddr = null;
public static String originHost = null;
- // FIXME: HACK
+ // FIXME: HACK: these shouldn't be set globally
public static String userAgent = "Ibex";
+ public static boolean allowRedirects = true;
// Cookies //////////////////////////////////////////////////////////////////////////////
releaseMe.release();
return makeRequest(contentType, content, referer, cookies);
+ } else if (reply.startsWith("3") && allowRedirects) {
+ String location = (String)h.get("location");
+ if (location == null) throw new HTTPException("Got HTTP " + reply.substring(0, 3) + " but no Location header");
+ Log.info(HTTP.class, "redirecting to " + location);
+ if (content != null)
+ return new HTTP(location).POST(contentType, content, url, cookies);
+ else
+ return new HTTP(location).GET(url, cookies);
+
} else if (reply.startsWith("2")) {
if (h.get("HTTP").equals("1.0") && h.get("content-length") == null)
throw new HTTPException("Ibex does not support HTTP/1.0 servers which fail to return the Content-Length header");