@@ -43,6 +43,7 @@ import static org.apache.http.HttpHeaders.LOCATION; | |||||
import static org.cobbzilla.util.daemon.ZillaRuntime.*; | import static org.cobbzilla.util.daemon.ZillaRuntime.*; | ||||
import static org.cobbzilla.util.http.HttpContentTypes.APPLICATION_OCTET_STREAM; | import static org.cobbzilla.util.http.HttpContentTypes.APPLICATION_OCTET_STREAM; | ||||
import static org.cobbzilla.util.http.HttpMethods.*; | import static org.cobbzilla.util.http.HttpMethods.*; | ||||
import static org.cobbzilla.util.http.HttpSchemes.isHttpOrHttps; | |||||
import static org.cobbzilla.util.http.HttpStatusCodes.*; | import static org.cobbzilla.util.http.HttpStatusCodes.*; | ||||
import static org.cobbzilla.util.io.FileUtil.getDefaultTempDir; | import static org.cobbzilla.util.io.FileUtil.getDefaultTempDir; | ||||
import static org.cobbzilla.util.json.JsonUtil.fromJson; | import static org.cobbzilla.util.json.JsonUtil.fromJson; | ||||
@@ -341,7 +342,7 @@ public class ApiClientBase implements Cloneable, Closeable { | |||||
} | } | ||||
private String getUrl(String path, String clientUri) { | private String getUrl(String path, String clientUri) { | ||||
if (path.startsWith("http://") || path.startsWith("https://")) { | |||||
if (isHttpOrHttps(path)) { | |||||
return path; // caller has supplied an absolute path | return path; // caller has supplied an absolute path | ||||
} else if (path.startsWith("/") && clientUri.endsWith("/")) { | } else if (path.startsWith("/") && clientUri.endsWith("/")) { | ||||
@@ -21,6 +21,7 @@ import java.util.Map; | |||||
import static java.util.concurrent.TimeUnit.SECONDS; | import static java.util.concurrent.TimeUnit.SECONDS; | ||||
import static org.cobbzilla.util.daemon.ZillaRuntime.*; | import static org.cobbzilla.util.daemon.ZillaRuntime.*; | ||||
import static org.cobbzilla.util.http.HttpSchemes.isHttpOrHttps; | |||||
import static org.cobbzilla.util.json.JsonUtil.json; | import static org.cobbzilla.util.json.JsonUtil.json; | ||||
import static org.cobbzilla.util.system.Sleep.sleep; | import static org.cobbzilla.util.system.Sleep.sleep; | ||||
import static org.cobbzilla.util.time.TimeUtil.parseDuration; | import static org.cobbzilla.util.time.TimeUtil.parseDuration; | ||||
@@ -156,7 +157,7 @@ public class SimpleApiRunnerListener extends ApiRunnerListenerBase { | |||||
private String formatUrl(String url) { | private String formatUrl(String url) { | ||||
final ApiClientBase currentApi = currentApi(); | final ApiClientBase currentApi = currentApi(); | ||||
if (!url.startsWith("http://") && !url.startsWith("https://")) { | |||||
if (!isHttpOrHttps(url)) { | |||||
if (!url.startsWith("/") && !currentApi.getBaseUri().endsWith("/")) url = "/" + url; | if (!url.startsWith("/") && !currentApi.getBaseUri().endsWith("/")) url = "/" + url; | ||||
url = currentApi.getBaseUri() + url; | url = currentApi.getBaseUri() + url; | ||||
} | } | ||||
@@ -16,6 +16,7 @@ import java.util.concurrent.ConcurrentHashMap; | |||||
import static java.util.concurrent.TimeUnit.DAYS; | import static java.util.concurrent.TimeUnit.DAYS; | ||||
import static org.cobbzilla.util.daemon.ZillaRuntime.CLASSPATH_PREFIX; | import static org.cobbzilla.util.daemon.ZillaRuntime.CLASSPATH_PREFIX; | ||||
import static org.cobbzilla.util.daemon.ZillaRuntime.empty; | import static org.cobbzilla.util.daemon.ZillaRuntime.empty; | ||||
import static org.cobbzilla.util.http.HttpSchemes.isHttpOrHttps; | |||||
import static org.cobbzilla.util.string.StringUtil.chop; | import static org.cobbzilla.util.string.StringUtil.chop; | ||||
import static org.cobbzilla.util.string.StringUtil.trimQuotes; | import static org.cobbzilla.util.string.StringUtil.trimQuotes; | ||||
@@ -62,7 +63,7 @@ public class LegalInfo { | |||||
if (empty(value)) return ""; | if (empty(value)) return ""; | ||||
if (!empty(getBase())) value = chop(getBase(), "/") + "/" + value; | if (!empty(getBase())) value = chop(getBase(), "/") + "/" + value; | ||||
if (value.startsWith("http://") || value.startsWith("https://")) { | |||||
if (isHttpOrHttps(value)) { | |||||
try { | try { | ||||
return HttpUtil.getResponse(value).getEntityString(); | return HttpUtil.getResponse(value).getEntityString(); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
@@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit; | |||||
import static org.cobbzilla.util.daemon.ZillaRuntime.die; | import static org.cobbzilla.util.daemon.ZillaRuntime.die; | ||||
import static org.cobbzilla.util.daemon.ZillaRuntime.empty; | import static org.cobbzilla.util.daemon.ZillaRuntime.empty; | ||||
import static org.cobbzilla.util.http.HttpSchemes.SCHEME_HTTP; | |||||
import static org.cobbzilla.util.network.NetworkUtil.getLocalhostIpv4; | import static org.cobbzilla.util.network.NetworkUtil.getLocalhostIpv4; | ||||
import static org.cobbzilla.util.reflect.ReflectionUtil.forName; | import static org.cobbzilla.util.reflect.ReflectionUtil.forName; | ||||
import static org.cobbzilla.util.reflect.ReflectionUtil.instantiate; | import static org.cobbzilla.util.reflect.ReflectionUtil.instantiate; | ||||
@@ -55,7 +56,7 @@ public class RestServerConfiguration { | |||||
@Setter private String publicUriBase; | @Setter private String publicUriBase; | ||||
public String getPublicUriBase () { | public String getPublicUriBase () { | ||||
if (empty(publicUriBase)) return "http://"+getLocalhostIpv4()+":"+getHttp().getPort(); | |||||
if (empty(publicUriBase)) return SCHEME_HTTP+getLocalhostIpv4()+":"+getHttp().getPort(); | |||||
return !empty(publicUriBase) && publicUriBase.endsWith("/") ? publicUriBase.substring(0, publicUriBase.length()-1) : publicUriBase; | return !empty(publicUriBase) && publicUriBase.endsWith("/") ? publicUriBase.substring(0, publicUriBase.length()-1) : publicUriBase; | ||||
} | } | ||||