diff --git a/wizard-common/src/main/java/org/cobbzilla/wizard/client/ApiClientBase.java b/wizard-common/src/main/java/org/cobbzilla/wizard/client/ApiClientBase.java index 3747af0..195b222 100644 --- a/wizard-common/src/main/java/org/cobbzilla/wizard/client/ApiClientBase.java +++ b/wizard-common/src/main/java/org/cobbzilla/wizard/client/ApiClientBase.java @@ -43,6 +43,7 @@ import static org.apache.http.HttpHeaders.LOCATION; import static org.cobbzilla.util.daemon.ZillaRuntime.*; import static org.cobbzilla.util.http.HttpContentTypes.APPLICATION_OCTET_STREAM; 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.io.FileUtil.getDefaultTempDir; 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) { - if (path.startsWith("http://") || path.startsWith("https://")) { + if (isHttpOrHttps(path)) { return path; // caller has supplied an absolute path } else if (path.startsWith("/") && clientUri.endsWith("/")) { diff --git a/wizard-common/src/main/java/org/cobbzilla/wizard/client/script/SimpleApiRunnerListener.java b/wizard-common/src/main/java/org/cobbzilla/wizard/client/script/SimpleApiRunnerListener.java index 8e37dad..17b44e2 100644 --- a/wizard-common/src/main/java/org/cobbzilla/wizard/client/script/SimpleApiRunnerListener.java +++ b/wizard-common/src/main/java/org/cobbzilla/wizard/client/script/SimpleApiRunnerListener.java @@ -21,6 +21,7 @@ import java.util.Map; import static java.util.concurrent.TimeUnit.SECONDS; 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.system.Sleep.sleep; import static org.cobbzilla.util.time.TimeUtil.parseDuration; @@ -156,7 +157,7 @@ public class SimpleApiRunnerListener extends ApiRunnerListenerBase { private String formatUrl(String url) { final ApiClientBase currentApi = currentApi(); - if (!url.startsWith("http://") && !url.startsWith("https://")) { + if (!isHttpOrHttps(url)) { if (!url.startsWith("/") && !currentApi.getBaseUri().endsWith("/")) url = "/" + url; url = currentApi.getBaseUri() + url; } diff --git a/wizard-server/src/main/java/org/cobbzilla/wizard/server/config/LegalInfo.java b/wizard-server/src/main/java/org/cobbzilla/wizard/server/config/LegalInfo.java index 76832ba..71be616 100644 --- a/wizard-server/src/main/java/org/cobbzilla/wizard/server/config/LegalInfo.java +++ b/wizard-server/src/main/java/org/cobbzilla/wizard/server/config/LegalInfo.java @@ -16,6 +16,7 @@ import java.util.concurrent.ConcurrentHashMap; import static java.util.concurrent.TimeUnit.DAYS; import static org.cobbzilla.util.daemon.ZillaRuntime.CLASSPATH_PREFIX; 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.trimQuotes; @@ -62,7 +63,7 @@ public class LegalInfo { if (empty(value)) return ""; if (!empty(getBase())) value = chop(getBase(), "/") + "/" + value; - if (value.startsWith("http://") || value.startsWith("https://")) { + if (isHttpOrHttps(value)) { try { return HttpUtil.getResponse(value).getEntityString(); } catch (IOException e) { diff --git a/wizard-server/src/main/java/org/cobbzilla/wizard/server/config/RestServerConfiguration.java b/wizard-server/src/main/java/org/cobbzilla/wizard/server/config/RestServerConfiguration.java index 96d2f9b..1be69e7 100644 --- a/wizard-server/src/main/java/org/cobbzilla/wizard/server/config/RestServerConfiguration.java +++ b/wizard-server/src/main/java/org/cobbzilla/wizard/server/config/RestServerConfiguration.java @@ -31,6 +31,7 @@ import java.util.concurrent.TimeUnit; import static org.cobbzilla.util.daemon.ZillaRuntime.die; 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.reflect.ReflectionUtil.forName; import static org.cobbzilla.util.reflect.ReflectionUtil.instantiate; @@ -55,7 +56,7 @@ public class RestServerConfiguration { @Setter private String publicUriBase; 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; }