Commit adc6a035 authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

441: Fix issues related to deployment of upcoming v4-release (OPENED)

Task-Url: #441
parent f765b540
package eu.dariah.de.search.api.client.base;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
......@@ -109,7 +110,23 @@ public abstract class BaseApiClientImpl<TBase, TExt> implements ApiClient {
ApiStatusPojo result = new ApiStatusPojo();
Stopwatch sw = new Stopwatch().start();
try {
HttpURLConnection connection = (HttpURLConnection)new URL(this.getPingUrl()).openConnection();
String location;
URL baseURL = new URL(this.getPingUrl());
URL nextURL;
HttpURLConnection connection = (HttpURLConnection)baseURL.openConnection();
int redirects = 0;
while(connection.getResponseCode()==HttpURLConnection.HTTP_MOVED_PERM ||
connection.getResponseCode()==HttpURLConnection.HTTP_MOVED_TEMP) {
if (++redirects > 10) {
throw new IOException("Too many redirects; connect cancelled");
}
location = connection.getHeaderField("Location");
nextURL = new URL(baseURL, location); // Handle relative URLs
baseURL = nextURL;
connection = (HttpURLConnection)baseURL.openConnection();
}
result.setStatusCode(connection.getResponseCode());
result.setRoundtime(sw.getElapsedTime());
result.setAccessible(true);
......
Subproject commit 45dab02681cc7a853e706618f76344d22d3f445b
Subproject commit af2a4c85bcf339986256c41090cbf4fac7c4aaa2
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment