diff options
Diffstat (limited to 'org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/HttpUtil.java')
-rw-r--r-- | org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/HttpUtil.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/HttpUtil.java b/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/HttpUtil.java new file mode 100644 index 000000000..1f7edc382 --- /dev/null +++ b/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/HttpUtil.java @@ -0,0 +1,24 @@ +package org.eclipse.osee.ote.master.rest.client.internal; + +import java.net.HttpURLConnection; +import java.net.URI; +import java.util.logging.Level; + +import org.eclipse.osee.framework.logging.OseeLog; + +public class HttpUtil { + + public static boolean canConnect(URI targetUri) { + try{ + HttpURLConnection connection = (HttpURLConnection)targetUri.toURL().openConnection(); + connection.setRequestMethod("HEAD"); + int responseCode = connection.getResponseCode(); + if(responseCode == 200){ + return true; + } + } catch (Throwable th){ + OseeLog.log(HttpUtil.class, Level.INFO, th); + } + return false; + } +} |